52 return std::make_shared<RBMBuilder>(label);
63 const std::string& label) :
66 nhidden, nvisible, weight_init, bias_init,
hidden_key)),
69 auto hidden_contents =
hidden_->get_contents();
70 auto weight = hidden_contents[0];
71 auto hbias = hidden_contents[1];
78 visible_ = std::make_shared<Dense>(tenncor::transpose(
84 UnaryptrT activation, std::string label) :
94 std::string label_prefix =
"")
108 RBM (
RBM&& other) =
default;
145 auto out =
hidden_->get_contents();
146 auto vis_contents =
visible_->get_contents();
148 out.insert(out.end(), vis_contents.begin(), vis_contents.end());
149 out.insert(out.end(), act_contents.begin(), act_contents.end());
168 return new RBM(*
this, label_prefix);
173 auto hidden_subs =
hidden_->get_contents();
174 for (
auto&
sub : hidden_subs)
183 auto visible_subs =
visible_->get_contents();
184 for (
auto&
sub : visible_subs)
193 auto activation_subs =
activation_->get_contents();
194 for (
auto&
sub : activation_subs)
205 auto hidden_contents =
hidden_->get_contents();
207 if (
auto vbias = other.
visible_->get_contents()[1])
212 visible_ = std::make_shared<Dense>(tenncor::transpose(
234 #endif // LAYR_RBM_HPP
Builder implementation for restricted boltzmann layer.
Definition: rbm.hpp:25
size_t get_ninput(void) const override
Implementation of iLayer.
Definition: rbm.hpp:119
const std::string dense_bias_key
Fully connected bias label.
Definition: dense.hpp:24
Layer implementation to apply fully_connect functions to weight and optional bias.
Definition: dense.hpp:72
LayerRegistry & get_layer_reg(void)
Return global layer registry reference.
RBM * clone(std::string label_prefix="") const
Return deep copy of this layer with prefixed label.
Definition: rbm.hpp:113
LayerptrT build(void) const override
Implementation of iLayerBuilder.
Definition: rbm.cpp:8
std::shared_ptr< Dense > DenseptrT
Smart pointer of fully connected layer.
Definition: dense.hpp:201
std::string register_tagr(std::string key, LayerBuildF builder)
Definition: layer.hpp:198
std::vector< LayerptrT > layers_
Definition: rbm.hpp:42
size_t get_noutput(void) const override
Implementation of iLayer.
Definition: rbm.hpp:125
std::shared_ptr< iLayerBuilder > LBuilderptrT
Layer builder smart pointer.
Definition: layer.hpp:179
std::shared_ptr< ULayer > UnaryptrT
Smart pointer of unary layer.
Definition: ulayer.hpp:200
DenseptrT visible_
Definition: rbm.hpp:224
NodeptrT connect(NodeptrT visible) const override
Implementation of iLayer.
Definition: rbm.hpp:154
std::string get_label(void) const override
Implementation of iLayer.
Definition: rbm.hpp:137
const std::string layers_key_prefix
String prefixed to every layer key.
Definition: layer.hpp:25
std::function< eteq::VarptrT< T >(teq::Shape, std::string)> InitF
Function that produces a variable given the variable's shape and label.
Definition: init.hpp:20
Definition: layer.hpp:164
DenseptrT hidden_
Definition: rbm.hpp:222
teq::TensptrsT get_contents(void) const override
Implementation of iLayer.
Definition: rbm.hpp:143
EigenptrT< T > sub(teq::Shape &outshape, const OpArg< T > &a, const OpArg< T > &b)
Definition: operator.hpp:679
std::string get_ltype(void) const override
Implementation of iLayer.
Definition: rbm.hpp:131
void tag(teq::TensptrT tensor, LayerId subs) const
std::shared_ptr< iTensor > TensptrT
Tensor smart pointer.
Definition: itensor.hpp:51
RBM(const RBM &other, std::string label_prefix="")
Definition: rbm.hpp:93
RBM(teq::DimT nhidden, teq::DimT nvisible, UnaryptrT activation, layr::InitF< PybindT > weight_init, layr::InitF< PybindT > bias_init, const std::string &label)
Definition: rbm.hpp:59
void set_tensor(teq::TensptrT tens, std::string target) override
Implementation of iLayerBuilder.
Definition: rbm.hpp:30
std::vector< TensptrT > TensptrsT
Vector of tensor smart pointers.
Definition: itensor.hpp:60
Sublayer type, label, and index encapsulation.
Definition: layer.hpp:35
RBM(DenseptrT hidden, DenseptrT visible, UnaryptrT activation, std::string label)
Definition: rbm.hpp:83
uint16_t DimT
Type used for shape dimension.
Definition: shape.hpp:31
RBM & operator=(const RBM &other)
Definition: rbm.hpp:99
NodeptrT backward_connect(NodeptrT hidden) const
Return visible reconstruction from hidden.
Definition: rbm.hpp:160
void copy_helper(const RBM &other, std::string label_prefix="")
Definition: rbm.hpp:201
void tag_sublayers(void)
Definition: rbm.hpp:171
std::shared_ptr< iNode< T > > NodeptrT
Smart pointer of node.
Definition: inode.hpp:63
std::string label_
Definition: rbm.hpp:44
UnaryptrT activation_
Definition: rbm.hpp:226
void set_sublayer(LayerptrT layer) override
Implementation of iLayerBuilder.
Definition: rbm.hpp:33
RBMBuilder(std::string label)
Definition: rbm.hpp:27
std::shared_ptr< iLayer > LayerptrT
Smart pointer of layer.
Definition: layer.hpp:159
iLayer * clone_impl(const std::string &label_prefix) const override
Definition: rbm.hpp:166
const std::string hidden_key
Hidden fully connected layer label.
Definition: rbm.hpp:19
const std::string rbm_layer_key
Identifier for restricted boltzmann machine.
Definition: rbm.hpp:48
Definition: layer.hpp:121
Node registry of tensor types and tensor to node function.
Definition: inode.hpp:75
std::shared_ptr< RBM > RBMptrT
Smart pointer of RBM layer.
Definition: rbm.hpp:230
const std::string visible_key
Visible fully connected layer label.
Definition: rbm.hpp:22
std::string label_
Definition: rbm.hpp:220