IgANet
IGAnets - Isogeometric Analysis Networks
Loading...
Searching...
No Matches
iganet::IgANet< Optimizer, Inputs, Outputs, CollPts > Class Template Referenceabstract

IgANet. More...

#include </home/runner/work/iganet/iganet/include/iganet/net/iganet.hpp>

Inheritance diagram for iganet::IgANet< Optimizer, Inputs, Outputs, CollPts >:
iganet::IgABase< typename, typename, typename > iganet::utils::Serializable iganet::utils::FullQualifiedName fitting< Optimizer, GeometryMap, Variable > fitting< Optimizer, GeometryMap, Variable > fitting< Optimizer, GeometryMap, Variable > fitting< Optimizer, GeometryMap, Variable > fitting< Optimizer, GeometryMap, Variable > poisson< Optimizer, GeometryMap, Variable >

Public Types

using Base = IgABase< Inputs, Outputs, CollPts >
 Base type.
 
using optimizer_options_type = optimizer_options_type< Optimizer >::type
 Type of the optimizer options.
 
using optimizer_type = Optimizer
 Type of the optimizer.
 
using value_type = Base::value_type
 Value type.
 

Public Member Functions

 IgANet (const IgANetOptions &defaults={}, iganet::Options< typename Base::value_type > options=iganet::Options< typename Base::value_type >{})
 Default constructor.
 
template<typename NumCoeffs >
 IgANet (const std::vector< int64_t > &layers, const std::vector< std::vector< std::any > > &activations, const NumCoeffs &numCoeffs, enum init init=init::greville, IgANetOptions defaults={}, iganet::Options< typename Base::value_type > options=iganet::Options< typename Base::value_type >{})
 Constructor: number of layers, activation functions, and number of spline coefficients (same for all inputs and outputs).
 
template<typename NumCoeffsInputs , typename NumCoeffsOutputs >
 IgANet (const std::vector< int64_t > &layers, const std::vector< std::vector< std::any > > &activations, const NumCoeffsInputs &numCoeffsInputs, const NumCoeffsOutputs &numCoeffsOutputs, enum init init=init::greville, IgANetOptions defaults={}, iganet::Options< typename Base::value_type > options=iganet::Options< typename Base::value_type >{})
 Constructor: number of layers, activation functions, and number of spline coefficients (same for all inputs and outputs).
 
virtual bool epoch (int64_t)=0
 Initializes epoch.
 
void eval ()
 Evaluate IgANet.
 
constexpr auto & inputs ()
 Returns a non-constant reference to the tuple of input objects.
 
constexpr const auto & inputs () const
 Returns a constant reference to the tuple of input objects.
 
virtual void inputs (const torch::Tensor &tensor)
 Attaches the given tensor to the inputs.
 
virtual torch::Tensor inputs (int64_t epoch) const
 Returns the network inputs as tensor.
 
void load (const std::string &filename, const std::string &key="iganet")
 Loads the IgANet from file.
 
virtual torch::Tensor loss (const torch::Tensor &, int64_t)=0
 Computes the loss function.
 
torch::OrderedDict< std::string, torch::Tensor > named_parameters () const noexcept
 Returns a constant reference to the named parameters of the IgANet object.
 
IgANetGenerator< typename Base::value_type > & net ()
 Returns a non-constant reference to the IgANet generator.
 
const IgANetGenerator< typename Base::value_type > & net () const
 Returns a constant reference to the IgANet generator.
 
std::size_t nparameters () const noexcept
 Returns the total number of parameters of the IgANet object.
 
bool operator!= (const IgANet &other) const
 Returns true if both IgANet objects are different.
 
bool operator== (const IgANet &other) const
 Returns true if both IgANet objects are the same.
 
optimizer_typeoptimizer ()
 Returns a non-constant reference to the optimizer.
 
const optimizer_typeoptimizer () const
 Returns a constant reference to the optimizer.
 
optimizer_options_typeoptimizerOptions (std::size_t param_group=0)
 Returns a non-constant reference to the optimizer options.
 
const optimizer_options_typeoptimizerOptions (std::size_t param_group=0) const
 Returns a constant reference to the optimizer options.
 
void optimizerOptionsReset (const optimizer_options_type &options)
 Resets the optimizer options.
 
void optimizerOptionsReset (const optimizer_options_type &options, std::size_t param_group)
 Resets the optimizer options.
 
void optimizerOptionsReset (optimizer_options_type &&options)
 Resets the optimizer options.
 
void optimizerOptionsReset (optimizer_options_type &&options, std::size_t param_group)
 Resets the optimizer options.
 
void optimizerReset (bool resetOptions=true)
 Resets the optimizer.
 
void optimizerReset (const optimizer_options_type &optimizerOptions)
 Resets the optimizer.
 
auto & options ()
 Returns a non-constant reference to the options structure.
 
const auto & options () const
 Returns a constant reference to the options structure.
 
constexpr auto & outputs ()
 Returns a non-constant reference to the tuple of output objects.
 
constexpr const auto & outputs () const
 Returns a constant reference to the tuple of output objects.
 
virtual void outputs (const torch::Tensor &tensor)
 Attaches the given tensor to the outputs.
 
virtual torch::Tensor outputs (int64_t epoch) const
 Returns the network outputs as tensor.
 
std::vector< torch::Tensor > parameters () const noexcept
 Returns a constant reference to the parameters of the IgANet object.
 
void pretty_print (std::ostream &os) const noexcept override
 Returns a string representation of the IgANet object.
 
torch::serialize::InputArchive & read (torch::serialize::InputArchive &archive, const std::string &key="iganet")
 Loads the IgANet from a torch::serialize::InputArchive object.
 
torch::Tensor & register_parameter (std::string name, torch::Tensor tensor, bool requires_grad=true)
 Registers a parameter.
 
void save (const std::string &filename, const std::string &key="iganet") const
 Saves the IgANet to file.
 
nlohmann::json to_json () const override
 Returns the IgANet object as JSON object.
 
virtual void train ()
 Trains the IgANet.
 
template<typename DataLoader >
void train (DataLoader &loader)
 Trains the IgANet.
 
torch::serialize::OutputArchive & write (torch::serialize::OutputArchive &archive, const std::string &key="iganet") const
 Writes the IgANet into a torch::serialize::OutputArchive object.
 

Protected Attributes

IgANetGenerator< typename Base::value_type > net_
 IgANet generator.
 
std::unique_ptr< optimizer_typeopt_
 Optimizer.
 
IgANetOptions options_
 Options.
 

Additional Inherited Members

- Private Member Functions inherited from iganet::utils::Serializable
virtual ~Serializable ()=default
 Destructor.
 
- Private Member Functions inherited from iganet::utils::FullQualifiedName
virtual ~FullQualifiedName ()=default
 
virtual const std::string & name () const noexcept
 Returns the full qualified name of the object.
 
- Private Attributes inherited from iganet::utils::FullQualifiedName
at::optional< std::string > name_
 String storing the full qualified name of the object.
 

Detailed Description

template<typename Optimizer, typename Inputs, typename Outputs, typename CollPts = void>
requires OptimizerType<Optimizer>
class iganet::IgANet< Optimizer, Inputs, Outputs, CollPts >

IgANet.

This class implements the core functionality of IgANets.

Member Typedef Documentation

◆ Base

template<typename Optimizer , typename Inputs , typename Outputs , typename CollPts = void>
using iganet::IgANet< Optimizer, Inputs, Outputs, CollPts >::Base = IgABase<Inputs, Outputs, CollPts>

Base type.

◆ optimizer_options_type

template<typename Optimizer , typename Inputs , typename Outputs , typename CollPts = void>
using iganet::IgANet< Optimizer, Inputs, Outputs, CollPts >::optimizer_options_type = optimizer_options_type<Optimizer>::type

Type of the optimizer options.

◆ optimizer_type

template<typename Optimizer , typename Inputs , typename Outputs , typename CollPts = void>
using iganet::IgANet< Optimizer, Inputs, Outputs, CollPts >::optimizer_type = Optimizer

Type of the optimizer.

◆ value_type

template<typename Optimizer , typename Inputs , typename Outputs , typename CollPts = void>
using iganet::IgANet< Optimizer, Inputs, Outputs, CollPts >::value_type = Base::value_type

Value type.

Constructor & Destructor Documentation

◆ IgANet() [1/3]

template<typename Optimizer , typename Inputs , typename Outputs , typename CollPts = void>
iganet::IgANet< Optimizer, Inputs, Outputs, CollPts >::IgANet ( const IgANetOptions defaults = {},
iganet::Options< typename Base::value_type >  options = iganet::Options<typename Base::value_type>{} 
)
inlineexplicit

Default constructor.

Parameters
defaultsValue of defaults.
optionsConfiguration options.

◆ IgANet() [2/3]

template<typename Optimizer , typename Inputs , typename Outputs , typename CollPts = void>
template<typename NumCoeffs >
iganet::IgANet< Optimizer, Inputs, Outputs, CollPts >::IgANet ( const std::vector< int64_t > &  layers,
const std::vector< std::vector< std::any > > &  activations,
const NumCoeffs &  numCoeffs,
enum init  init = init::greville,
IgANetOptions  defaults = {},
iganet::Options< typename Base::value_type >  options = iganet::Options<typename Base::value_type>{} 
)
inline

Constructor: number of layers, activation functions, and number of spline coefficients (same for all inputs and outputs).

Template Parameters
NumCoeffsTemplate parameter NumCoeffs.
Parameters
layersValue of layers.
activationsValue of activations.
numCoeffsValue of numCoeffs.
initValue of init.
defaultsValue of defaults.
optionsConfiguration options.

◆ IgANet() [3/3]

template<typename Optimizer , typename Inputs , typename Outputs , typename CollPts = void>
template<typename NumCoeffsInputs , typename NumCoeffsOutputs >
iganet::IgANet< Optimizer, Inputs, Outputs, CollPts >::IgANet ( const std::vector< int64_t > &  layers,
const std::vector< std::vector< std::any > > &  activations,
const NumCoeffsInputs &  numCoeffsInputs,
const NumCoeffsOutputs &  numCoeffsOutputs,
enum init  init = init::greville,
IgANetOptions  defaults = {},
iganet::Options< typename Base::value_type >  options = iganet::Options<typename Base::value_type>{} 
)
inline

Constructor: number of layers, activation functions, and number of spline coefficients (same for all inputs and outputs).

Template Parameters
NumCoeffsInputsTemplate parameter NumCoeffsInputs.
NumCoeffsOutputsTemplate parameter NumCoeffsOutputs.
Parameters
layersValue of layers.
activationsValue of activations.
numCoeffsInputsValue of numCoeffsInputs.
numCoeffsOutputsValue of numCoeffsOutputs.
initValue of init.
defaultsValue of defaults.
optionsConfiguration options.

Member Function Documentation

◆ epoch()

◆ eval()

template<typename Optimizer , typename Inputs , typename Outputs , typename CollPts = void>
void iganet::IgANet< Optimizer, Inputs, Outputs, CollPts >::eval ( )
inline

Evaluate IgANet.

◆ inputs() [1/4]

template<typename Optimizer , typename Inputs , typename Outputs , typename CollPts = void>
constexpr auto & iganet::IgANet< Optimizer, Inputs, Outputs, CollPts >::inputs ( )
inlineconstexpr

Returns a non-constant reference to the tuple of input objects.

Returns
Result of the operation.

◆ inputs() [2/4]

template<typename Optimizer , typename Inputs , typename Outputs , typename CollPts = void>
constexpr const auto & iganet::IgANet< Optimizer, Inputs, Outputs, CollPts >::inputs ( ) const
inlineconstexpr

Returns a constant reference to the tuple of input objects.

Returns
Result of the operation.

◆ inputs() [3/4]

template<typename Optimizer , typename Inputs , typename Outputs , typename CollPts = void>
virtual void iganet::IgANet< Optimizer, Inputs, Outputs, CollPts >::inputs ( const torch::Tensor &  tensor)
inlinevirtual

Attaches the given tensor to the inputs.

Parameters
tensorTensor to process.

◆ inputs() [4/4]

template<typename Optimizer , typename Inputs , typename Outputs , typename CollPts = void>
virtual torch::Tensor iganet::IgANet< Optimizer, Inputs, Outputs, CollPts >::inputs ( int64_t  epoch) const
inlinevirtual

Returns the network inputs as tensor.

Parameters
epochValue of epoch.
Returns
Result of the operation.

◆ load()

template<typename Optimizer , typename Inputs , typename Outputs , typename CollPts = void>
void iganet::IgANet< Optimizer, Inputs, Outputs, CollPts >::load ( const std::string &  filename,
const std::string &  key = "iganet" 
)
inline

Loads the IgANet from file.

Parameters
filenamePath of the file to process.
keySerialization key.

◆ loss()

◆ named_parameters()

template<typename Optimizer , typename Inputs , typename Outputs , typename CollPts = void>
torch::OrderedDict< std::string, torch::Tensor > iganet::IgANet< Optimizer, Inputs, Outputs, CollPts >::named_parameters ( ) const
inlinenoexcept

Returns a constant reference to the named parameters of the IgANet object.

Returns
Result of the operation.

◆ net() [1/2]

template<typename Optimizer , typename Inputs , typename Outputs , typename CollPts = void>
IgANetGenerator< typename Base::value_type > & iganet::IgANet< Optimizer, Inputs, Outputs, CollPts >::net ( )
inline

Returns a non-constant reference to the IgANet generator.

Returns
Result of the operation.

◆ net() [2/2]

template<typename Optimizer , typename Inputs , typename Outputs , typename CollPts = void>
const IgANetGenerator< typename Base::value_type > & iganet::IgANet< Optimizer, Inputs, Outputs, CollPts >::net ( ) const
inline

Returns a constant reference to the IgANet generator.

Returns
Result of the operation.

◆ nparameters()

template<typename Optimizer , typename Inputs , typename Outputs , typename CollPts = void>
std::size_t iganet::IgANet< Optimizer, Inputs, Outputs, CollPts >::nparameters ( ) const
inlinenoexcept

Returns the total number of parameters of the IgANet object.

Returns
Result of the operation.

◆ operator!=()

template<typename Optimizer , typename Inputs , typename Outputs , typename CollPts = void>
bool iganet::IgANet< Optimizer, Inputs, Outputs, CollPts >::operator!= ( const IgANet< Optimizer, Inputs, Outputs, CollPts > &  other) const
inline

Returns true if both IgANet objects are different.

Parameters
otherSecond input value.
Returns
Result of the operation.

◆ operator==()

template<typename Optimizer , typename Inputs , typename Outputs , typename CollPts = void>
bool iganet::IgANet< Optimizer, Inputs, Outputs, CollPts >::operator== ( const IgANet< Optimizer, Inputs, Outputs, CollPts > &  other) const
inline

Returns true if both IgANet objects are the same.

Parameters
otherSecond input value.
Returns
Result of the operation.

◆ optimizer() [1/2]

template<typename Optimizer , typename Inputs , typename Outputs , typename CollPts = void>
optimizer_type & iganet::IgANet< Optimizer, Inputs, Outputs, CollPts >::optimizer ( )
inline

Returns a non-constant reference to the optimizer.

Returns
Result of the operation.

◆ optimizer() [2/2]

template<typename Optimizer , typename Inputs , typename Outputs , typename CollPts = void>
const optimizer_type & iganet::IgANet< Optimizer, Inputs, Outputs, CollPts >::optimizer ( ) const
inline

Returns a constant reference to the optimizer.

Returns
Result of the operation.

◆ optimizerOptions() [1/2]

template<typename Optimizer , typename Inputs , typename Outputs , typename CollPts = void>
optimizer_options_type & iganet::IgANet< Optimizer, Inputs, Outputs, CollPts >::optimizerOptions ( std::size_t  param_group = 0)
inline

Returns a non-constant reference to the optimizer options.

Parameters
param_groupValue of param_group.
Returns
Result of the operation.

◆ optimizerOptions() [2/2]

template<typename Optimizer , typename Inputs , typename Outputs , typename CollPts = void>
const optimizer_options_type & iganet::IgANet< Optimizer, Inputs, Outputs, CollPts >::optimizerOptions ( std::size_t  param_group = 0) const
inline

Returns a constant reference to the optimizer options.

Parameters
param_groupValue of param_group.
Returns
Result of the operation.

◆ optimizerOptionsReset() [1/4]

template<typename Optimizer , typename Inputs , typename Outputs , typename CollPts = void>
void iganet::IgANet< Optimizer, Inputs, Outputs, CollPts >::optimizerOptionsReset ( const optimizer_options_type options)
inline

Resets the optimizer options.

Parameters
optionsConfiguration options.

◆ optimizerOptionsReset() [2/4]

template<typename Optimizer , typename Inputs , typename Outputs , typename CollPts = void>
void iganet::IgANet< Optimizer, Inputs, Outputs, CollPts >::optimizerOptionsReset ( const optimizer_options_type options,
std::size_t  param_group 
)
inline

Resets the optimizer options.

Parameters
optionsConfiguration options.
param_groupValue of param_group.

◆ optimizerOptionsReset() [3/4]

template<typename Optimizer , typename Inputs , typename Outputs , typename CollPts = void>
void iganet::IgANet< Optimizer, Inputs, Outputs, CollPts >::optimizerOptionsReset ( optimizer_options_type &&  options)
inline

Resets the optimizer options.

Parameters
optionsConfiguration options.

◆ optimizerOptionsReset() [4/4]

template<typename Optimizer , typename Inputs , typename Outputs , typename CollPts = void>
void iganet::IgANet< Optimizer, Inputs, Outputs, CollPts >::optimizerOptionsReset ( optimizer_options_type &&  options,
std::size_t  param_group 
)
inline

Resets the optimizer options.

Parameters
optionsConfiguration options.
param_groupValue of param_group.

◆ optimizerReset() [1/2]

template<typename Optimizer , typename Inputs , typename Outputs , typename CollPts = void>
void iganet::IgANet< Optimizer, Inputs, Outputs, CollPts >::optimizerReset ( bool  resetOptions = true)
inline

Resets the optimizer.

Parameters
[in]resetOptionsFlag to indicate whether the optimizer options should be resetted.

◆ optimizerReset() [2/2]

template<typename Optimizer , typename Inputs , typename Outputs , typename CollPts = void>
void iganet::IgANet< Optimizer, Inputs, Outputs, CollPts >::optimizerReset ( const optimizer_options_type optimizerOptions)
inline

Resets the optimizer.

Parameters
optimizerOptionsValue of optimizerOptions.

◆ options() [1/2]

template<typename Optimizer , typename Inputs , typename Outputs , typename CollPts = void>
auto & iganet::IgANet< Optimizer, Inputs, Outputs, CollPts >::options ( )
inline

Returns a non-constant reference to the options structure.

Returns
Result of the operation.

◆ options() [2/2]

template<typename Optimizer , typename Inputs , typename Outputs , typename CollPts = void>
const auto & iganet::IgANet< Optimizer, Inputs, Outputs, CollPts >::options ( ) const
inline

Returns a constant reference to the options structure.

Returns
Result of the operation.

◆ outputs() [1/4]

template<typename Optimizer , typename Inputs , typename Outputs , typename CollPts = void>
constexpr auto & iganet::IgANet< Optimizer, Inputs, Outputs, CollPts >::outputs ( )
inlineconstexpr

Returns a non-constant reference to the tuple of output objects.

Returns
Result of the operation.

◆ outputs() [2/4]

template<typename Optimizer , typename Inputs , typename Outputs , typename CollPts = void>
constexpr const auto & iganet::IgANet< Optimizer, Inputs, Outputs, CollPts >::outputs ( ) const
inlineconstexpr

Returns a constant reference to the tuple of output objects.

Returns
Result of the operation.

◆ outputs() [3/4]

template<typename Optimizer , typename Inputs , typename Outputs , typename CollPts = void>
virtual void iganet::IgANet< Optimizer, Inputs, Outputs, CollPts >::outputs ( const torch::Tensor &  tensor)
inlinevirtual

Attaches the given tensor to the outputs.

Parameters
tensorTensor to process.

◆ outputs() [4/4]

template<typename Optimizer , typename Inputs , typename Outputs , typename CollPts = void>
virtual torch::Tensor iganet::IgANet< Optimizer, Inputs, Outputs, CollPts >::outputs ( int64_t  epoch) const
inlinevirtual

Returns the network outputs as tensor.

Parameters
epochValue of epoch.
Returns
Result of the operation.

◆ parameters()

template<typename Optimizer , typename Inputs , typename Outputs , typename CollPts = void>
std::vector< torch::Tensor > iganet::IgANet< Optimizer, Inputs, Outputs, CollPts >::parameters ( ) const
inlinenoexcept

Returns a constant reference to the parameters of the IgANet object.

Returns
Result of the operation.

◆ pretty_print()

template<typename Optimizer , typename Inputs , typename Outputs , typename CollPts = void>
void iganet::IgANet< Optimizer, Inputs, Outputs, CollPts >::pretty_print ( std::ostream &  os) const
inlineoverridevirtualnoexcept

Returns a string representation of the IgANet object.

Parameters
osOutput stream.

Implements iganet::utils::Serializable.

◆ read()

template<typename Optimizer , typename Inputs , typename Outputs , typename CollPts = void>
torch::serialize::InputArchive & iganet::IgANet< Optimizer, Inputs, Outputs, CollPts >::read ( torch::serialize::InputArchive &  archive,
const std::string &  key = "iganet" 
)
inline

Loads the IgANet from a torch::serialize::InputArchive object.

Parameters
archiveSerialization archive.
keySerialization key.
Returns
Result of the operation.

◆ register_parameter()

template<typename Optimizer , typename Inputs , typename Outputs , typename CollPts = void>
torch::Tensor & iganet::IgANet< Optimizer, Inputs, Outputs, CollPts >::register_parameter ( std::string  name,
torch::Tensor  tensor,
bool  requires_grad = true 
)
inline

Registers a parameter.

Parameters
nameValue of name.
tensorTensor to process.
requires_gradValue of requires_grad.
Returns
Result of the operation.

◆ save()

template<typename Optimizer , typename Inputs , typename Outputs , typename CollPts = void>
void iganet::IgANet< Optimizer, Inputs, Outputs, CollPts >::save ( const std::string &  filename,
const std::string &  key = "iganet" 
) const
inline

Saves the IgANet to file.

Parameters
filenamePath of the file to process.
keySerialization key.

◆ to_json()

template<typename Optimizer , typename Inputs , typename Outputs , typename CollPts = void>
nlohmann::json iganet::IgANet< Optimizer, Inputs, Outputs, CollPts >::to_json ( ) const
inlineoverridevirtual

Returns the IgANet object as JSON object.

Returns
Result of the operation.

Implements iganet::utils::Serializable.

◆ train() [1/2]

template<typename Optimizer , typename Inputs , typename Outputs , typename CollPts = void>
virtual void iganet::IgANet< Optimizer, Inputs, Outputs, CollPts >::train ( )
inlinevirtual

Trains the IgANet.

◆ train() [2/2]

template<typename Optimizer , typename Inputs , typename Outputs , typename CollPts = void>
template<typename DataLoader >
void iganet::IgANet< Optimizer, Inputs, Outputs, CollPts >::train ( DataLoader &  loader)
inline

Trains the IgANet.

Template Parameters
DataLoaderTemplate parameter DataLoader.
Parameters
loaderTraining data loader.

◆ write()

template<typename Optimizer , typename Inputs , typename Outputs , typename CollPts = void>
torch::serialize::OutputArchive & iganet::IgANet< Optimizer, Inputs, Outputs, CollPts >::write ( torch::serialize::OutputArchive &  archive,
const std::string &  key = "iganet" 
) const
inline

Writes the IgANet into a torch::serialize::OutputArchive object.

Parameters
archiveSerialization archive.
keySerialization key.
Returns
Result of the operation.

Member Data Documentation

◆ net_

template<typename Optimizer , typename Inputs , typename Outputs , typename CollPts = void>
IgANetGenerator<typename Base::value_type> iganet::IgANet< Optimizer, Inputs, Outputs, CollPts >::net_
protected

IgANet generator.

◆ opt_

template<typename Optimizer , typename Inputs , typename Outputs , typename CollPts = void>
std::unique_ptr<optimizer_type> iganet::IgANet< Optimizer, Inputs, Outputs, CollPts >::opt_
protected

Optimizer.

◆ options_

template<typename Optimizer , typename Inputs , typename Outputs , typename CollPts = void>
IgANetOptions iganet::IgANet< Optimizer, Inputs, Outputs, CollPts >::options_
protected

The documentation for this class was generated from the following file: