5 #include "../neuron/neuron.h"
16 std::string _activate_function =
18 std::vector<Neuron> _neurons;
19 std::vector<Variable> _parameters;
28 Layer(
size_t n_in,
size_t n_out, std::string activate_function =
"tanh")
29 : _n_in(n_in), _n_out(n_out), _activate_function(activate_function)
31 _parameters.reserve((n_in + 1) * n_out);
32 _neurons.reserve(n_out);
33 for (
size_t i = 0; i < n_out; i++)
35 _neurons.emplace_back(n_in, _activate_function);
36 for (
size_t j = 0; j < _neurons[i].parameters().size(); j++)
38 _parameters.push_back(_neurons[i].
parameters()[j]);
48 : _n_in(other._n_in), _n_out(other._n_out),
49 _activate_function(other._activate_function),
50 _neurons(other._neurons){};
60 _n_out = other._n_out;
61 _activate_function = other._activate_function;
62 _neurons = other._neurons;
73 _n_out = other._n_out;
74 _activate_function = std::move(other._activate_function);
75 _neurons = std::move(other._neurons);
87 _n_out = other._n_out;
88 _activate_function = std::move(other._activate_function);
89 _neurons = std::move(other._neurons);
115 std::vector<Variable>
forward(
const std::vector<double> &inputs);
122 std::vector<Variable>
forward(
const std::vector<Variable> &variables);
Layer & operator=(const Layer &other)
Definition: layer.h:57
const std::vector< Neuron > & neurons() const
Definition: layer.h:105
std::vector< Variable > forward(const std::vector< double > &inputs)
Definition: layer.cc:4
const std::vector< Variable > & parameters() const
Definition: layer.h:96
Layer(const Layer &other)
Definition: layer.h:47
Layer(Layer &&other) noexcept
Definition: layer.h:84
Layer(size_t n_in, size_t n_out, std::string activate_function="tanh")
Definition: layer.h:28
Layer & operator=(Layer &&other) noexcept
Definition: layer.h:70