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

IgANet2. More...

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

Inheritance diagram for iganet::IgANet2< Optimizer, Inputs, Outputs, CollPts >:
iganet::IgABase2< typename, typename, typename > iganet::utils::Serializable iganet::utils::FullQualifiedName

Public Types

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

Public Member Functions

template<typename NumCoeffs >
 IgANet2 (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 >
 IgANet2 (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)
 
 IgANet2 (IgANetOptions defaults={}, iganet::Options< typename Base::value_type > options=iganet::Options< typename Base::value_type >{})
 Default constructor.
 
virtual bool epoch (int64_t)=0
 Initializes epoch.
 
void eval ()
 Evaluate IgANet.
 
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 IgANet2 &other) const
 Returns true if both IgANet objects are different.
 
bool operator== (const IgANet2 &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.
 
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.
 
virtual void pretty_print (std::ostream &os=Log(log::info)) 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.
 
void save (const std::string &filename, const std::string &key="iganet") const
 Saves the IgANet to file.
 
virtual 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::FullQualifiedName
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::IgANet2< Optimizer, Inputs, Outputs, CollPts >

IgANet2.

This class implements the core functionality of IgANets

Member Typedef Documentation

◆ Base

template<typename Optimizer , typename Inputs , typename Outputs , typename CollPts = void>
using iganet::IgANet2< Optimizer, Inputs, Outputs, CollPts >::Base = IgABase2<Inputs, Outputs, CollPts>

Base type.

◆ optimizer_options_type

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

Type of the optimizer options.

◆ optimizer_type

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

Type of the optimizer.

Constructor & Destructor Documentation

◆ IgANet2() [1/3]

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

Default constructor.

◆ IgANet2() [2/3]

template<typename Optimizer , typename Inputs , typename Outputs , typename CollPts = void>
template<typename NumCoeffs >
iganet::IgANet2< Optimizer, Inputs, Outputs, CollPts >::IgANet2 ( 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)

◆ IgANet2() [3/3]

template<typename Optimizer , typename Inputs , typename Outputs , typename CollPts = void>
template<typename NumCoeffsInputs , typename NumCoeffsOutputs >
iganet::IgANet2< Optimizer, Inputs, Outputs, CollPts >::IgANet2 ( 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)

Member Function Documentation

◆ epoch()

template<typename Optimizer , typename Inputs , typename Outputs , typename CollPts = void>
virtual bool iganet::IgANet2< Optimizer, Inputs, Outputs, CollPts >::epoch ( int64_t  )
pure virtual

Initializes epoch.

◆ eval()

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

Evaluate IgANet.

◆ inputs() [1/2]

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

Attaches the given tensor to the inputs.

◆ inputs() [2/2]

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

Returns the network inputs as tensor.

◆ load()

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

Loads the IgANet from file.

◆ loss()

template<typename Optimizer , typename Inputs , typename Outputs , typename CollPts = void>
virtual torch::Tensor iganet::IgANet2< Optimizer, Inputs, Outputs, CollPts >::loss ( const torch::Tensor &  ,
int64_t   
)
pure virtual

Computes the loss function.

◆ named_parameters()

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

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

◆ net() [1/2]

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

Returns a non-constant reference to the IgANet generator.

◆ net() [2/2]

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

Returns a constant reference to the IgANet generator.

◆ nparameters()

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

Returns the total number of parameters of the IgANet object.

◆ operator!=()

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

Returns true if both IgANet objects are different.

◆ operator==()

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

Returns true if both IgANet objects are the same.

◆ optimizer() [1/2]

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

Returns a non-constant reference to the optimizer.

◆ optimizer() [2/2]

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

Returns a constant reference to the optimizer.

◆ optimizerOptions() [1/2]

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

Returns a non-constant reference to the optimizer options.

◆ optimizerOptions() [2/2]

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

Returns a constant reference to the optimizer options.

◆ optimizerOptionsReset() [1/4]

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

Resets the optimizer options.

◆ optimizerOptionsReset() [2/4]

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

Resets the optimizer options.

◆ optimizerOptionsReset() [3/4]

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

Resets the optimizer options.

◆ optimizerOptionsReset() [4/4]

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

Resets the optimizer options.

◆ optimizerReset() [1/2]

template<typename Optimizer , typename Inputs , typename Outputs , typename CollPts = void>
void iganet::IgANet2< 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::IgANet2< Optimizer, Inputs, Outputs, CollPts >::optimizerReset ( const optimizer_options_type optimizerOptions)
inline

Resets the optimizer.

◆ options() [1/2]

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

Returns a non-constant reference to the options structure.

◆ options() [2/2]

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

Returns a constant reference to the options structure.

◆ outputs() [1/2]

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

Attaches the given tensor to the outputs.

◆ outputs() [2/2]

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

Returns the network outputs as tensor.

◆ parameters()

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

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

◆ pretty_print()

template<typename Optimizer , typename Inputs , typename Outputs , typename CollPts = void>
virtual void iganet::IgANet2< Optimizer, Inputs, Outputs, CollPts >::pretty_print ( std::ostream &  os = Log(log::info)) const
inlineoverridevirtualnoexcept

Returns a string representation of the IgANet object.

Implements iganet::utils::Serializable.

◆ read()

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

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

◆ save()

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

Saves the IgANet to file.

◆ to_json()

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

Returns the IgANet object as JSON object.

Implements iganet::utils::Serializable.

◆ train() [1/2]

template<typename Optimizer , typename Inputs , typename Outputs , typename CollPts = void>
virtual void iganet::IgANet2< 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::IgANet2< Optimizer, Inputs, Outputs, CollPts >::train ( DataLoader &  loader)
inline

Trains the IgANet.

◆ write()

template<typename Optimizer , typename Inputs , typename Outputs , typename CollPts = void>
torch::serialize::OutputArchive & iganet::IgANet2< 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.

Member Data Documentation

◆ net_

template<typename Optimizer , typename Inputs , typename Outputs , typename CollPts = void>
IgANetGenerator<typename Base::value_type> iganet::IgANet2< 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::IgANet2< Optimizer, Inputs, Outputs, CollPts >::opt_
protected

Optimizer.

◆ options_

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

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