Base class for covariance functions that are used in Gaussian Processes. More...
#include <CovarianceFunctionBase.h>
Public Types | |
| using | HyperParameterMap = std::unordered_map< std::string, torch::Tensor > |
| typedef DataFileName | DataFileParameterType |
Public Member Functions | |
| CovarianceFunctionBase (const InputParameters ¶meters) | |
| virtual void | computeCovarianceMatrix (torch::Tensor &K, const torch::Tensor &x, const torch::Tensor &xp, const bool is_self_covariance) const =0 |
| Generates the Covariance Matrix given two sets of points in the parameter space. More... | |
| void | loadHyperParamMap (const HyperParameterMap &map) |
| Load some hyperparameters into the local map contained in this object. More... | |
| void | buildHyperParamMap (HyperParameterMap &map) const |
| Populates the input maps with the owned hyperparameters. More... | |
| virtual bool | getTuningData (const std::string &name, unsigned int &size, Real &min, Real &max) const |
| Get the default minimum and maximum and size of a hyperparameter. More... | |
| void | dependentCovarianceTypes (std::map< UserObjectName, std::string > &name_type_map) const |
| Populate a map with the names and types of the dependent covariance functions. More... | |
| const std::vector< UserObjectName > & | dependentCovarianceNames () const |
| Get the names of the dependent covariances. More... | |
| virtual bool | computedKdhyper (torch::Tensor &dKdhp, const torch::Tensor &x, const std::string &hyper_param_name, unsigned int ind) const |
| Redirect dK/dhp for hyperparameter "hp". More... | |
| virtual bool | isTunable (const std::string &name) const |
| Check if a given parameter is tunable. More... | |
| unsigned int | numOutputs () const |
| Return the number of outputs assumed for this covariance function. More... | |
| virtual bool | enabled () const |
| std::shared_ptr< MooseObject > | getSharedPtr () |
| std::shared_ptr< const MooseObject > | getSharedPtr () const |
| bool | isKokkosObject () const |
| MooseApp & | getMooseApp () const |
| const std::string & | type () const |
| const std::string & | name () const |
| std::string | typeAndName () const |
| MooseObjectParameterName | uniqueParameterName (const std::string ¶meter_name) const |
| MooseObjectName | uniqueName () const |
| const InputParameters & | parameters () const |
| const hit::Node * | getHitNode () const |
| bool | hasBase () const |
| const std::string & | getBase () const |
| const T & | getParam (const std::string &name) const |
| std::vector< std::pair< T1, T2 > > | getParam (const std::string ¶m1, const std::string ¶m2) const |
| const T * | queryParam (const std::string &name) const |
| const T & | getRenamedParam (const std::string &old_name, const std::string &new_name) const |
| T | getCheckedPointerParam (const std::string &name, const std::string &error_string="") const |
| bool | isParamValid (const std::string &name) const |
| bool | isParamSetByUser (const std::string &name) const |
| void | connectControllableParams (const std::string ¶meter, const std::string &object_type, const std::string &object_name, const std::string &object_parameter) const |
| void | paramError (const std::string ¶m, Args... args) const |
| void | paramWarning (const std::string ¶m, Args... args) const |
| void | paramWarning (const std::string ¶m, Args... args) const |
| void | paramInfo (const std::string ¶m, Args... args) const |
| std::string | messagePrefix (const bool hit_prefix=true) const |
| std::string | errorPrefix (const std::string &) const |
| void | mooseError (Args &&... args) const |
| void | mooseDocumentedError (const std::string &repo_name, const unsigned int issue_num, Args &&... args) const |
| void | mooseErrorNonPrefixed (Args &&... args) const |
| void | mooseWarning (Args &&... args) const |
| void | mooseWarning (Args &&... args) const |
| void | mooseWarningNonPrefixed (Args &&... args) const |
| void | mooseWarningNonPrefixed (Args &&... args) const |
| void | mooseDeprecated (Args &&... args) const |
| void | mooseDeprecated (Args &&... args) const |
| void | mooseDeprecatedNoTrace (Args &&... args) const |
| void | mooseInfo (Args &&... args) const |
| void | callMooseError (std::string msg, const bool with_prefix, const hit::Node *node=nullptr, const bool show_trace=true) const |
| std::string | getDataFileName (const std::string ¶m) const |
| std::string | getDataFileNameByName (const std::string &relative_path) const |
| std::string | getDataFilePath (const std::string &relative_path) const |
| const Parallel::Communicator & | comm () const |
| processor_id_type | n_processors () const |
| processor_id_type | processor_id () const |
Static Public Member Functions | |
| static bool | isScalarHyperParameter (const torch::Tensor &tensor) |
| Return true if a hyperparameter tensor stores one scalar value. More... | |
| static bool | isVectorHyperParameter (const torch::Tensor &tensor) |
| Return true if a hyperparameter tensor stores a vector of values. More... | |
| static InputParameters | validParams () |
| static void | callMooseError (MooseApp *const app, const InputParameters ¶ms, std::string msg, const bool with_prefix, const hit::Node *node, const bool show_trace=true) |
Public Attributes | |
| usingCombinedWarningSolutionWarnings | |
| const ConsoleStream | _console |
Static Public Attributes | |
| static const std::string | type_param |
| static const std::string | name_param |
| static const std::string | unique_name_param |
| static const std::string | app_param |
| static const std::string | moose_base_param |
| static const std::string | kokkos_object_param |
Protected Member Functions | |
| torch::Tensor & | addRealHyperParameter (const std::string &name, const Real value, const bool is_tunable) |
| Register a scalar hyperparameter to this covariance function. More... | |
| torch::Tensor & | addVectorRealHyperParameter (const std::string &name, const std::vector< Real > &value, const bool is_tunable) |
| Register a vector hyperparameter to this covariance function. More... | |
| void | flagInvalidSolutionInternal (const InvalidSolutionID invalid_solution_id) const |
| InvalidSolutionID | registerInvalidSolutionInternal (const std::string &message, const bool warning) const |
| CovarianceFunctionBase * | getCovarianceFunctionByName (const UserObjectName &name) const |
| Lookup a CovarianceFunction object by name and return pointer. More... | |
Protected Attributes | |
| HyperParameterMap | _hyperparameters |
| Map of hyperparameters stored as rank-0 or rank-1 tensors. More... | |
| std::unordered_set< std::string > | _tunable_hp |
| list of tunable hyper-parameters More... | |
| const unsigned int | _num_outputs |
| The number of outputs this covariance function is used to describe. More... | |
| const std::vector< UserObjectName > | _dependent_covariance_names |
| The names of the dependent covariance functions. More... | |
| std::vector< std::string > | _dependent_covariance_types |
| The types of the dependent covariance functions. More... | |
| std::vector< CovarianceFunctionBase * > | _covariance_functions |
| Vector of pointers to the dependent covariance functions. More... | |
| const bool & | _enabled |
| MooseApp & | _app |
| Factory & | _factory |
| ActionFactory & | _action_factory |
| const std::string & | _type |
| const std::string & | _name |
| const InputParameters & | _pars |
| const Parallel::Communicator & | _communicator |
Base class for covariance functions that are used in Gaussian Processes.
Definition at line 20 of file CovarianceFunctionBase.h.
| using CovarianceFunctionBase::HyperParameterMap = std::unordered_map<std::string, torch::Tensor> |
Definition at line 23 of file CovarianceFunctionBase.h.
| CovarianceFunctionBase::CovarianceFunctionBase | ( | const InputParameters & | parameters | ) |
Definition at line 69 of file CovarianceFunctionBase.C.
|
protected |
Register a scalar hyperparameter to this covariance function.
| name | The name of the parameter |
| value | The initial value of the parameter |
| is_tunable | If the parameter is tunable during optimization |
Definition at line 95 of file CovarianceFunctionBase.C.
|
protected |
Register a vector hyperparameter to this covariance function.
| name | The name of the parameter |
| value | The initial value of the parameter |
| is_tunable | If the parameter is tunable during optimization |
Definition at line 105 of file CovarianceFunctionBase.C.
Referenced by LMC::LMC().
| void CovarianceFunctionBase::buildHyperParamMap | ( | HyperParameterMap & | map | ) | const |
Populates the input maps with the owned hyperparameters.
| map | Map of hyperparameters that should be populated |
Definition at line 153 of file CovarianceFunctionBase.C.
Referenced by StochasticTools::GaussianProcess::setupCovarianceMatrix().
|
pure virtual |
Generates the Covariance Matrix given two sets of points in the parameter space.
| K | Reference to a matrix which should be populated by the covariance entries |
| x | Reference to the first set of points |
| xp | Reference to the second set of points |
| is_self_covariance | Switch to enable adding the noise variance to the diagonal of the covariance matrix |
Implemented in LMC, ExponentialCovariance, MaternHalfIntCovariance, and SquaredExponentialCovariance.
Referenced by GaussianProcessSurrogate::evaluate(), StochasticTools::GaussianProcess::getLoss(), and StochasticTools::GaussianProcess::setupCovarianceMatrix().
|
virtual |
Redirect dK/dhp for hyperparameter "hp".
Returns false is the parameter has not been found in this covariance object.
| dKdhp | The matrix which should be populated with the derivatives |
| x | The input vector for which the derivatives of the covariance matrix is computed |
| hyper_param_name | The name of the hyperparameter |
| ind | The index within the hyperparameter. 0 if it is a scalar parameter. If it is a vector parameter, it should be the index within the vector. |
Reimplemented in ExponentialCovariance, MaternHalfIntCovariance, SquaredExponentialCovariance, and LMC.
Definition at line 85 of file CovarianceFunctionBase.C.
Referenced by StochasticTools::GaussianProcess::getGradient().
|
inline |
Get the names of the dependent covariances.
Definition at line 67 of file CovarianceFunctionBase.h.
Referenced by StochasticTools::GaussianProcess::linkCovarianceFunction().
| void CovarianceFunctionBase::dependentCovarianceTypes | ( | std::map< UserObjectName, std::string > & | name_type_map | ) | const |
Populate a map with the names and types of the dependent covariance functions.
| name_type_map | Reference to the map which should be populated |
Definition at line 204 of file CovarianceFunctionBase.C.
Referenced by StochasticTools::GaussianProcess::linkCovarianceFunction().
|
protectedinherited |
Lookup a CovarianceFunction object by name and return pointer.
Definition at line 26 of file CovarianceInterface.C.
Referenced by ActiveLearningGaussianProcess::ActiveLearningGaussianProcess(), CovarianceFunctionBase(), GaussianProcessTrainer::GaussianProcessTrainer(), and GaussianProcessSurrogate::setupCovariance().
|
virtual |
Get the default minimum and maximum and size of a hyperparameter.
Returns false is the parameter has not been found in this covariance object.
| name | The name of the hyperparameter |
| size | Reference to an unsigned int that will contain the size of the hyperparameter (will be populated with 1 if it is scalar) |
| min | Reference to a number which will be populated by the maximum allowed value of the hyperparameter |
| max | Reference to a number which will be populated by the minimum allowed value of the hyperparameter |
Definition at line 168 of file CovarianceFunctionBase.C.
Referenced by StochasticTools::GaussianProcess::generateTuningMap().
|
static |
Return true if a hyperparameter tensor stores one scalar value.
Definition at line 44 of file CovarianceFunctionBase.C.
Referenced by buildHyperParamMap(), getTuningData(), GaussianProcessData::initialize(), and loadHyperParamMap().
|
virtual |
Check if a given parameter is tunable.
| The | name of the hyperparameter |
Definition at line 115 of file CovarianceFunctionBase.C.
Referenced by StochasticTools::GaussianProcess::generateTuningMap().
|
static |
Return true if a hyperparameter tensor stores a vector of values.
Definition at line 50 of file CovarianceFunctionBase.C.
Referenced by buildHyperParamMap(), getTuningData(), GaussianProcessData::initialize(), and loadHyperParamMap().
| void CovarianceFunctionBase::loadHyperParamMap | ( | const HyperParameterMap & | map | ) |
Load some hyperparameters into the local map contained in this object.
| map | Input map of hyperparameters |
Definition at line 131 of file CovarianceFunctionBase.C.
Referenced by LoadCovarianceDataAction::load(), StochasticTools::GaussianProcess::setupCovarianceMatrix(), and StochasticTools::GaussianProcess::tuneHyperParamsAdam().
|
inline |
Return the number of outputs assumed for this covariance function.
Definition at line 90 of file CovarianceFunctionBase.h.
Referenced by GaussianProcessSurrogate::evaluate(), GaussianProcessTrainer::GaussianProcessTrainer(), and StochasticTools::GaussianProcess::linkCovarianceFunction().
|
static |
Definition at line 56 of file CovarianceFunctionBase.C.
Referenced by ExponentialCovariance::validParams(), SquaredExponentialCovariance::validParams(), MaternHalfIntCovariance::validParams(), and LMC::validParams().
|
protected |
Vector of pointers to the dependent covariance functions.
Definition at line 124 of file CovarianceFunctionBase.h.
Referenced by buildHyperParamMap(), LMC::computeCovarianceMatrix(), LMC::computedKdhyper(), CovarianceFunctionBase(), dependentCovarianceTypes(), getTuningData(), isTunable(), and loadHyperParamMap().
|
protected |
The names of the dependent covariance functions.
Definition at line 118 of file CovarianceFunctionBase.h.
Referenced by CovarianceFunctionBase(), and dependentCovarianceNames().
|
protected |
The types of the dependent covariance functions.
Definition at line 121 of file CovarianceFunctionBase.h.
Referenced by CovarianceFunctionBase().
|
protected |
Map of hyperparameters stored as rank-0 or rank-1 tensors.
Definition at line 109 of file CovarianceFunctionBase.h.
Referenced by addRealHyperParameter(), addVectorRealHyperParameter(), buildHyperParamMap(), getTuningData(), isTunable(), and loadHyperParamMap().
|
protected |
The number of outputs this covariance function is used to describe.
Definition at line 115 of file CovarianceFunctionBase.h.
Referenced by LMC::computeCovarianceMatrix(), LMC::computedKdhyper(), LMC::computeLambdaGradient(), LMC::LMC(), and numOutputs().
|
protected |
list of tunable hyper-parameters
Definition at line 112 of file CovarianceFunctionBase.h.
Referenced by addRealHyperParameter(), addVectorRealHyperParameter(), LMC::computedKdhyper(), and isTunable().
1.8.14