9 #include "eteq/generated/api.hpp" 14 #ifndef LAYR_DENSE_HPP 15 #define LAYR_DENSE_HPP 44 logs::warnf(
"attempt to create dense layer " 45 "with unknown tensor `%s` of label `%s`",
46 tens->to_string().c_str(), target.c_str());
68 return std::make_shared<DenseBuilder>(label);
77 const std::string& label) :
102 std::string label_prefix =
"")
155 nullptr ==
bias_ ? nullptr :
bias_->get_tensor(),
162 auto out = tenncor::nn::fully_connect({input}, {
weight_},
bias_);
164 input->get_tensor().get(),
169 leaves.emplace(
bias_->get_tensor().get());
178 return new Dense(*
this, label_prefix);
205 #endif // LAYR_DENSE_HPP NodeptrT bias_
Definition: dense.hpp:197
std::unordered_set< teq::iTensor * > TensSetT
Hash set of raw tensor pointers.
Definition: itensor.hpp:63
Dense(teq::DimT nunits, teq::DimT indim, layr::InitF< PybindT > weight_init, layr::InitF< PybindT > bias_init, const std::string &label)
Definition: dense.hpp:74
const std::string dense_weight_key
Fully connected weight label.
Definition: dense.hpp:21
NodeptrT weight_
Definition: dense.hpp:195
const std::string dense_bias_key
Fully connected bias label.
Definition: dense.hpp:24
std::string label_
Definition: dense.hpp:60
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.
std::shared_ptr< Dense > DenseptrT
Smart pointer of fully connected layer.
Definition: dense.hpp:201
iLayer * clone_impl(const std::string &label_prefix) const override
Definition: dense.hpp:176
DenseBuilder(std::string label)
Definition: dense.hpp:29
static NodeptrT< T > to_node(teq::TensptrT tens)
Return node associated with tensor type.
Definition: inode.hpp:81
void copy_helper(const Dense &other, std::string label_prefix="")
Definition: dense.hpp:181
std::string register_tagr(std::string key, LayerBuildF builder)
Definition: layer.hpp:198
Dense & operator=(const Dense &other)
Definition: dense.hpp:107
void recursive_tag(teq::TensptrT root, teq::TensSetT ignores, LayerId subs) const
NodeptrT weight_
Definition: dense.hpp:56
std::shared_ptr< iLayerBuilder > LBuilderptrT
Layer builder smart pointer.
Definition: layer.hpp:179
LayerptrT build(void) const override
Implementation of iLayerBuilder.
Dense(NodeptrT weight, NodeptrT bias, std::string label)
Definition: dense.hpp:89
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
std::string get_ltype(void) const override
Implementation of iLayer.
Definition: dense.hpp:139
teq::TensptrsT get_contents(void) const override
Implementation of iLayer.
Definition: dense.hpp:151
void set_sublayer(LayerptrT layer) override
Implementation of iLayerBuilder.
Definition: dense.hpp:50
Dense(const Dense &other, std::string label_prefix="")
Definition: dense.hpp:101
void tag(teq::TensptrT tensor, LayerId subs) const
std::shared_ptr< iTensor > TensptrT
Tensor smart pointer.
Definition: itensor.hpp:51
std::vector< TensptrT > TensptrsT
Vector of tensor smart pointers.
Definition: itensor.hpp:60
Sublayer type, label, and index encapsulation.
Definition: layer.hpp:35
size_t get_noutput(void) const override
Implementation of iLayer.
Definition: dense.hpp:133
std::string label_
Definition: dense.hpp:193
void set_tensor(teq::TensptrT tens, std::string target) override
Implementation of iLayerBuilder.
Definition: dense.hpp:32
uint16_t DimT
Type used for shape dimension.
Definition: shape.hpp:31
size_t get_ninput(void) const override
Implementation of iLayer.
Definition: dense.hpp:127
std::string get_label(void) const override
Implementation of iLayer.
Definition: dense.hpp:145
const std::string dense_layer_key
Identifier for fully connected layer.
Definition: dense.hpp:64
std::shared_ptr< iNode< T > > NodeptrT
Smart pointer of node.
Definition: inode.hpp:63
Builder implementation for fully connected layer.
Definition: dense.hpp:27
std::shared_ptr< iLayer > LayerptrT
Smart pointer of layer.
Definition: layer.hpp:159
NodeptrT connect(NodeptrT input) const override
Implementation of iLayer.
Definition: dense.hpp:160
Definition: layer.hpp:121
NodeptrT bias_
Definition: dense.hpp:58
Dense * clone(std::string label_prefix="") const
Return deep copy of this layer with prefixed label.
Definition: dense.hpp:121