13 #ifndef XACC_ALGORITHM_RBM_CLASSIFICATION_CD_HPP_ 14 #define XACC_ALGORITHM_RBM_CLASSIFICATION_CD_HPP_ 16 #include "rbm_classification.hpp" 24 Eigen::VectorXd sample(Eigen::VectorXd& probs) {
25 Eigen::VectorXd tmp = probs + Eigen::VectorXd::Random(probs.size());
26 Eigen::VectorXd tmp2 = tmp.array().floor();
30 const std::string
name()
const override {
return "cd"; }
32 std::tuple<Eigen::MatrixXd, Eigen::VectorXd, Eigen::VectorXd>
33 compute(Eigen::MatrixXd &features, Eigen::MatrixXd &w, Eigen::VectorXd &v,
36 Eigen::VectorXd exp_h = options.get<Eigen::VectorXd>(
"dataexp_h");
37 Eigen::VectorXd h_sample = sample(exp_h);
39 Eigen::MatrixXd tmp = h_sample * w.transpose();
40 for (
int col = 0; col < tmp.cols(); col++) {
41 for (
int row = 0; row < tmp.rows(); row++) {
42 tmp(row, col) += v(col);
51 Eigen::MatrixXd w_expectation;
53 Eigen::VectorXd v_expectation = Eigen::VectorXd::Zero(v.size());
54 Eigen::VectorXd h_expectation = Eigen::VectorXd::Zero(v.size());
61 return std::make_tuple(w_expectation, v_expectation, h_expectation);
const std::string description() const override
Definition: contrastive_divergence.hpp:31
const std::string name() const override
Definition: contrastive_divergence.hpp:30
Definition: Accelerator.hpp:25
Definition: rbm_classification.hpp:24
Definition: contrastive_divergence.hpp:21
Definition: heterogeneous.hpp:45