Commit 68853a63 authored by Federico Allocati's avatar Federico Allocati
Browse files

Added stats Kernel and Mean Hyperparameters

parent 0c0344e4
......@@ -8,7 +8,9 @@
#include <limbo/stat/aggregated_observations.hpp>
#include <limbo/stat/observations.hpp>
#include <limbo/stat/gp_acquisitions.hpp>
#include <limbo/stat/gp_kernel_hparams.hpp>
#include <limbo/stat/gp_likelihood.hpp>
#include <limbo/stat/gp_mean_hparams.hpp>
#include <limbo/stat/gp_prediction_differences.hpp>
#include <limbo/stat/samples.hpp>
......
#ifndef LIMBO_STAT_GP_KERNEL_HPARAMS_HPP
#define LIMBO_STAT_GP_KERNEL_HPARAMS_HPP
#include <cmath>
#include <limbo/stat/stat_base.hpp>
namespace limbo {
namespace stat {
template <typename Params>
struct GPKernelHParams : public StatBase<Params> {
template <typename BO, typename AggregatorFunction>
void operator()(const BO& bo, const AggregatorFunction& afun, bool blacklisted)
{
if (!bo.stats_enabled() || bo.observations().empty())
return;
this->_create_log_file(bo, "gp_kernel_hparams.dat");
if (bo.total_iterations() == 0)
std::cout << "#iteration gp_kernel_hparams" << std::endl;
(*this->_log_file) << bo.total_iterations() << " " << bo.model().kernel_function().h_params().transpose() << std::endl;
}
};
}
}
#endif
#ifndef LIMBO_STAT_GP_MEAN_HPARAMS_HPP
#define LIMBO_STAT_GP_MEAN_HPARAMS_HPP
#include <cmath>
#include <limbo/stat/stat_base.hpp>
namespace limbo {
namespace stat {
template <typename Params>
struct GPMeanHParams : public StatBase<Params> {
template <typename BO, typename AggregatorFunction>
void operator()(const BO& bo, const AggregatorFunction& afun, bool blacklisted)
{
if (!bo.stats_enabled() || bo.observations().empty())
return;
this->_create_log_file(bo, "gp_mean_hparams.dat");
if (bo.total_iterations() == 0)
std::cout << "#iteration gp_mean_hparams" << std::endl;
(*this->_log_file) << bo.total_iterations() << " " << bo.model().mean_function().h_params().transpose() << std::endl;
}
};
}
}
#endif
......@@ -27,10 +27,8 @@ def create(bld):
inits = ['NoInit', 'RandomSampling', 'RandomSamplingGrid', 'GridSampling']
stats = ['Samples', 'Observations', 'AggregatedObservations', 'BestSamples', 'BestObservations', 'BestAggregatedObservations',
'BlSamples', 'GPPredictionDifferences', 'GPAcquisitions', 'GPLikelihood']
stops = ['MaxIterations', 'MaxPredictedValue']
stats = 'typedef boost::fusion::vector<' + ', '.join(['stat::' + stat + '<Params>' for stat in stats]) + '> stats_t;\n'
stops = ' typedef boost::fusion::vector<' + ', '.join(['stop::' + stop + '<Params>' for stop in stops]) + '> stops_t;\n'
stops = ['MaxIterations', 'MaxPredictedValue']
src_path = bld.path.abspath() + '/combinations'
if not os.path.exists(src_path):
......@@ -51,7 +49,13 @@ def create(bld):
for acqui in acquisitions:
for acqui_opt in optimizers:
for init in inits:
declarations = stats + stops
total_stats = stats
if kernel == 'SquaredExpARD':
total_stats.append('GPKernelHParams')
if mean == 'FunctionARD':
total_stats.append('GPMeanHParams')
declarations = 'typedef boost::fusion::vector<' + ', '.join(['stat::' + total_stats + '<Params>' for stat in stats]) + '> stats_t;\n'
declarations = declarations + ' typedef boost::fusion::vector<' + ', '.join(['stop::' + stop + '<Params>' for stop in stops]) + '> stops_t;\n'
declarations = declarations + ' typedef kernel::' + kernel + '<Params> kernel_' + str(i) + '_t;\n'
declarations = declarations + ' typedef mean::' + mean + '<Params' + ('' if (not mean in mean_additional_params) else ',' + ', '.join(mean_additional_params[mean])) + '>' + ' mean_' + str(i) + '_t;\n'
declarations = declarations + ' typedef model::gp::' + gp_lf_opt + '<Params> gp_lf_opt_' + str(i) + '_t;\n'
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment