9#ifdef MOOSE_LIBTORCH_ENABLED
21 "A reporter to support parallel active learning for Bayesian UQ tasks.");
22 params.
addRequiredParam<std::vector<UserObjectName>>(
"likelihoods",
"Names of likelihoods.");
24 "noise",
"noise",
"Name of the model noise term to pass to Likelihoods object.");
31 _new_var_samples(_al_sampler.getVarSamples()),
32 _var_prior(_al_sampler.getVarPrior()),
33 _var_test(_al_sampler.getVarSampleTries()),
34 _noise(declareValue<Real>(
"noise"))
37 for (
const UserObjectName &
name : getParam<std::vector<UserObjectName>>(
"likelihoods"))
57 const DenseMatrix<Real> & data_in)
59 std::vector<Real> tmp;
65 for (
unsigned int i = 0; i <
_props; ++i)
67 for (
unsigned int j = 0; j <
_n_dim; ++j)
68 tmp[j] = data_in(i, j);
84 for (
unsigned int i = 0; i <
_props; ++i)
87 out1[j] = data_out[j *
_props + i];
101 Real convergence_value = 0.0;
102 unsigned int num_valid = 0;
103 for (
unsigned int ii = 0; ii <
_props; ++ii)
111 convergence_value = std::sqrt(convergence_value) / num_valid;
112 return convergence_value;
118 std::vector<Real> tmp;
registerMooseObject("StochasticToolsApp", BayesianActiveLearner)
A reporter to support parallel active learning for Bayesian UQ tasks.
const Distribution * _var_prior
Storage for the prior over the variance.
dof_id_type _num_confg_params
Storage for the number of experimental configuration parameters.
const std::vector< Real > & _new_var_samples
Storage for new proposed variance samples.
void computeLogLikelihood(const std::vector< Real > &data_out)
Sets up the training data for the GP model for Bayesian UQ tasks.
std::vector< const LikelihoodFunctionBase * > _likelihoods
Storage for the likelihood objects to be utilized.
std::vector< Real > _log_likelihood
Storage for the computed log-likelihood values in each iteration of active learning.
virtual void setupGPData(const std::vector< Real > &data_out, const DenseMatrix< Real > &data_in) override
Sets up the training data for the GP model.
Real & _noise
Model noise term to pass to Likelihoods object.
virtual void evaluateGPTest() override
Evaluate the GP on all the test samples sent by the Sampler.
virtual void includeAdditionalInputs() override
Include additional inputs before evaluating the acquisition function.
const std::vector< Real > & _var_test
Storage for all the proposed variance samples to test the GP model.
dof_id_type _num_confg_values
Storage for the number of experimental configuration values.
static InputParameters validParams()
virtual Real computeConvergenceValue() override
Computes the convergence value during active learning.
BayesianActiveLearner(const InputParameters ¶meters)
unsigned int _n_dim_plus_var
The input dimension for GP for Bayesian problems with var, equal to Sampler columns + 1.
Fast Bayesian inference with the parallel active learning (partly inspired from El Gammal et al.
A generic reporter to support parallel active learning: re-trains GP and picks the next best batch.
std::vector< Real > _eval_outputs_current
The GP outputs from the current iteration before re-training (to evaluate convergence)
static InputParameters validParams()
std::vector< std::vector< Real > > _gp_inputs
Storage for the GP re-training inputs.
const SurrogateModel & _gp_eval
The GP evaluator object that permits re-evaluations.
unsigned int _n_dim
The input dimension for GP, equal to Sampler columns.
std::vector< Real > _gp_outputs
Storage for the GP re-training outputs.
std::vector< Real > _length_scales
Storage for the length scales after the GP training.
const std::vector< std::vector< Real > > & _inputs_test
Storage for all the proposed samples to test the GP model.
std::vector< std::vector< Real > > _inputs_test_modified
Storage for all the modified proposed samples to test the GP model.
BayesianActiveLearningSampler & _al_sampler
The base sampler.
dof_id_type _props
Storage for the number of parallel proposals.
std::vector< Real > _gp_std_test
Outputs of GP model standard deviation for the test samples.
std::vector< Real > _gp_outputs_test
Outputs of GP model for the test samples.
static InputParameters validParams()
LikelihoodFunctionBase * getLikelihoodFunctionByName(const UserObjectName &name) const
Lookup a LikelihoodFunction object by name and return pointer.
const std::string & name() const
dof_id_type getNumberOfConfigParams() const
Return the number of configuration parameters.
dof_id_type getNumberOfConfigValues() const
Return the number of configuration parameters.
dof_id_type getNumberOfCols() const
virtual Real evaluate(const std::vector< Real > &x) const
Evaluate surrogate model given a row of parameters.