A singular Riemannian geometry approach to Deep Neural Networks.
|
Generic layer class. More...
#include <layer.h>
Public Member Functions | |
layer () | |
layer (const std::vector< std::vector< double >> &weights_, const std::vector< double > &biases_) | |
layer (const std::vector< std::vector< double >> &weights_) | |
layer (const Eigen::MatrixXd &weights_) | |
layer (const Eigen::MatrixXd &weights_, const std::vector< double > &biases_) | |
layer (const Eigen::MatrixXd &weights_, const Eigen::VectorXd &biases_) | |
layer (const Eigen::MatrixXd &weights_, const Eigen::VectorXd &biases_, int in_dim, int out_dim) | |
virtual | ~layer () |
virtual Eigen::VectorXd | predict (const Eigen::VectorXd &input) |
virtual std::vector< Eigen::VectorXd > | predict_batch (const std::vector< Eigen::VectorXd > &input) |
const Eigen::VectorXd | get_biases () |
const Eigen::MatrixXd | get_weights () |
const Eigen::MatrixXd | get_weights_biases_as_mat () |
const Eigen::MatrixXd | get_weights_biases_as_vec_col_maj () |
const Eigen::MatrixXd | get_weights_biases_as_vec_row_maj () |
double | get_weight (int i, int j) |
double | get_bias (int i) |
void | set_biases (const Eigen::VectorXd &biases_) |
void | set_biases (const std::vector< double > &biases_) |
void | set_weights (const Eigen::MatrixXd &weights_) |
void | set_weight (int i, int j, double weight_) |
void | set_bias (int i, double bias_) |
void | set_weights_biases_compact (Eigen::MatrixXd &source) |
void | set_weights_biases (Eigen::MatrixXd &source) |
void | set_weights_biases_row_maj (Eigen::MatrixXd &source) |
int | get_num_nodes () |
int | get_input_size () |
int | get_weights_rows () |
int | get_weights_cols () |
std::string | get_type () |
virtual Eigen::MatrixXd | compute_partial_derivatives_wrt_inputs (Eigen::VectorXd &input)=0 |
virtual Eigen::MatrixXd | compute_partial_derivatives_wrt_weights_biases (Eigen::VectorXd &input)=0 |
void | transpose_weights () |
void | set_exp_max_cut (double exp_max_cut_) |
void | set_exp_zero_approx (double exp_zero_approx_) |
double | get_exp_max_cut () |
double | get_exp_zero_approx () |
Generic layer class.
The class layer is an abstract class to be used to realize different kind of layers.
|
inline |
Default constructor.
layer::layer | ( | const std::vector< std::vector< double >> & | weights_, |
const std::vector< double > & | biases_ | ||
) |
Initializes a generic layer given a matrix of weights and a vector of biases.
layer::layer | ( | const std::vector< std::vector< double >> & | weights_ | ) |
Initializes a generic layer given a matrix of weights and a vector of biases.
layer::layer | ( | const Eigen::MatrixXd & | weights_ | ) |
Initializes a generic layer given a matrix of weights and a vector of biases.
layer::layer | ( | const Eigen::MatrixXd & | weights_, |
const std::vector< double > & | biases_ | ||
) |
Initializes a generic layer given a matrix of weights and a vector of biases.
layer::layer | ( | const Eigen::MatrixXd & | weights_, |
const Eigen::VectorXd & | biases_ | ||
) |
Initializes a generic layer given a matrix of weights and a vector of biases.
layer::layer | ( | const Eigen::MatrixXd & | weights_, |
const Eigen::VectorXd & | biases_, | ||
int | in_dim, | ||
int | out_dim | ||
) |
Initializes a generic layer given a matrix of weights and a vector of biases.
|
inlinevirtual |
Default deconstructor.
|
pure virtual |
Computes the Jacobian matrix with respect to the input variables. The Jacobian is computer in reduced form.
Implemented in fc_layer_sg, fc_layer_sl, fc_layer_sm, and fc_layer_sp.
|
pure virtual |
Computes the Jacobian matrix with respect to weights and biases.
Implemented in fc_layer_sg, fc_layer_sl, fc_layer_sm, and fc_layer_sp.
double layer::get_bias | ( | int | i | ) |
Returns the bias of the i-th node.
const Eigen::VectorXd layer::get_biases | ( | ) |
Returns the biases of the layer.
double layer::get_exp_max_cut | ( | ) |
Returns the parameter exp_max_cut, controlling the approximations of \( f(x) = e^{-x} \) and \( f(x) = ln(1+e^{x}) \) for large values of the argument \( x \).
double layer::get_exp_zero_approx | ( | ) |
Returns the parameter exp_zero_approx, approximating \( f(x) = e^{-x} \) for large values of the argument \( x \).
int layer::get_input_size | ( | ) |
Returns the dimension of the input space of the layer.
int layer::get_num_nodes | ( | ) |
Returns the number of nodes of the layer.
std::string layer::get_type | ( | ) |
Returns the type of the layer.
double layer::get_weight | ( | int | i, |
int | j | ||
) |
Returns the (i-th,j-th) entry of the matrix of weights.
const Eigen::MatrixXd layer::get_weights | ( | ) |
Returns the weights of the layer.
const Eigen::MatrixXd layer::get_weights_biases_as_mat | ( | ) |
Returns the weights and the biases of the layers in a matrix whose last column is the vector of the biases.
const Eigen::MatrixXd layer::get_weights_biases_as_vec_col_maj | ( | ) |
Returns the weights and the biases of the layers as a column vector. The order is the following: Weights of the first node, bias of the first node, weights of the first node, bias of the second node, etc.
const Eigen::MatrixXd layer::get_weights_biases_as_vec_row_maj | ( | ) |
Returns the weights and the biases of the layers as a row vector. The order is the following: Weights of the first node, bias of the first node, weights of the first node, bias of the second node, etc.
int layer::get_weights_cols | ( | ) |
Returns the number of columns of the weights matrix.
int layer::get_weights_rows | ( | ) |
Returns the number of rows of the weights matrix.
|
inlinevirtual |
Computes the output of the layer given an Eigen::VectorXd as input.
Reimplemented in fc_layer_sg, fc_layer_sl, fc_layer_sp, and fc_layer_sm.
|
inlinevirtual |
Computes the outputs of the layer given a vector<Eigen::VectorXd> as input.
Reimplemented in fc_layer_sg, fc_layer_sl, and fc_layer_sp.
void layer::set_bias | ( | int | i, |
double | bias_ | ||
) |
Sets the bias of the i-th node.
void layer::set_biases | ( | const Eigen::VectorXd & | biases_ | ) |
Sets the biases of the layer.
void layer::set_biases | ( | const std::vector< double > & | biases_ | ) |
Sets the biases of the layer.
void layer::set_exp_max_cut | ( | double | exp_max_cut_ | ) |
Set the exp_max_cut parameter to approximate \( f(x) = e^{-x} \) and \( f(x) = ln(1+e^{x}) \) for large values of the argument \( x \).
void layer::set_exp_zero_approx | ( | double | exp_zero_approx_ | ) |
Set the exp_zero_approx parameter to approximate \( f(x) = e^{-x} \) and \( f(x) = ln(1+e^{x}) \) for large values of the argument \( x \).
void layer::set_weight | ( | int | i, |
int | j, | ||
double | weight_ | ||
) |
Sets the (i-th,j-th) weight of the layer.
void layer::set_weights | ( | const Eigen::MatrixXd & | weights_ | ) |
Sets the weights of the layer.
void layer::set_weights_biases | ( | Eigen::MatrixXd & | source | ) |
Sets the weights and the biases of the layer. The entries of the input (1 x N) matrix is the following: Weights of the first node, bias of the first node, weights of the first node, bias of the second node, etc.
void layer::set_weights_biases_compact | ( | Eigen::MatrixXd & | source | ) |
Sets the weights and the biases of the layer, passing a matrix whose last column is the vector of the biases.
void layer::set_weights_biases_row_maj | ( | Eigen::MatrixXd & | source | ) |
Sets the weights and the biases of the layer. The entries of the input (1 x N) matrix is the following: Weights of the first node, bias of the first node, weights of the first node, bias of the second node, etc.
void layer::transpose_weights | ( | ) |
Transposes the weights matrix of the layer.