MachineIntelligenceCore:NeuralNets
|
Class implementing a linear, fully connected layer. More...
#include <Linear.hpp>
Public Member Functions | |
Linear (size_t inputs_, size_t outputs_, std::string name_="Linear") | |
Linear (size_t input_height_, size_t input_width_, size_t input_depth_, size_t output_height_, size_t output_width_, size_t output_depth_, std::string name_="Linear") | |
virtual | ~Linear () |
void | forward (bool test_=false) |
void | backward () |
void | resetGrads () |
void | update (eT alpha_, eT decay_=0.0f) |
std::vector < mic::types::MatrixPtr< eT > > & | getWeightActivations () |
std::vector < mic::types::MatrixPtr< eT > > & | getWeightGradientActivations () |
std::vector < mic::types::MatrixPtr< eT > > & | getInverseWeightActivations () |
std::vector < mic::types::MatrixPtr< eT > > & | getInverseOutputActivations () |
eT | calculateMeanReconstructionError () |
![]() | |
Layer (size_t input_height_, size_t input_width_, size_t input_depth_, size_t output_height_, size_t output_width_, size_t output_depth_, LayerTypes layer_type_, std::string name_="layer") | |
virtual | ~Layer () |
mic::types::MatrixPtr< eT > | forward (mic::types::MatrixPtr< eT > x_, bool test=false) |
mic::types::MatrixPtr< eT > | backward (mic::types::MatrixPtr< eT > dy_) |
virtual void | resizeBatch (size_t batch_size_) |
template<typename loss > | |
mic::types::MatrixPtr< eT > | calculateNumericalGradient (mic::types::MatrixPtr< eT > x_, mic::types::MatrixPtr< eT > target_y_, mic::types::MatrixPtr< eT > param_, loss loss_, eT delta_) |
size_t | inputSize () |
Returns size (length) of inputs. More... | |
size_t | outputSize () |
Returns size (length) of outputs. More... | |
size_t | batchSize () |
Returns size (length) of (mini)batch. More... | |
const std::string | name () const |
Returns name of the layer. More... | |
mic::types::MatrixPtr< eT > | getParam (std::string name_) |
mic::types::MatrixPtr< eT > | getState (std::string name_) |
mic::types::MatrixPtr< eT > | getGradient (std::string name_) |
void | setState (std::string name_, mic::types::MatrixPtr< eT > mat_ptr_) |
template<typename omT > | |
void | setOptimization () |
const std::string | type () const |
virtual std::string | streamLayerParameters () |
mic::types::MatrixPtr< eT > | lazyReturnSampleFromBatch (mic::types::MatrixPtr< eT > batch_ptr_, mic::types::MatrixArray< eT > &array_, std::string id_, size_t sample_number_, size_t sample_size_) |
mic::types::MatrixPtr< eT > | lazyReturnInputSample (mic::types::MatrixPtr< eT > batch_ptr_, size_t sample_number_) |
mic::types::MatrixPtr< eT > | lazyReturnOutputSample (mic::types::MatrixPtr< eT > batch_ptr_, size_t sample_number_) |
mic::types::MatrixPtr< eT > | lazyReturnChannelFromSample (mic::types::MatrixPtr< eT > sample_ptr_, mic::types::MatrixArray< eT > &array_, std::string id_, size_t sample_number_, size_t channel_number_, size_t height_, size_t width_) |
mic::types::MatrixPtr< eT > | lazyReturnInputChannel (mic::types::MatrixPtr< eT > sample_ptr_, size_t sample_number_, size_t channel_number_) |
mic::types::MatrixPtr< eT > | lazyReturnOutputChannel (mic::types::MatrixPtr< eT > sample_ptr_, size_t sample_number_, size_t channel_number_) |
void | lazyAllocateMatrixVector (std::vector< std::shared_ptr< mic::types::Matrix< eT > > > &vector_, size_t vector_size_, size_t matrix_height_, size_t matrix_width_) |
virtual std::vector < std::shared_ptr < mic::types::Matrix< eT > > > & | getInputActivations () |
virtual std::vector < std::shared_ptr < mic::types::Matrix< eT > > > & | getInputGradientActivations () |
virtual std::vector < std::shared_ptr < mic::types::Matrix< eT > > > & | getOutputActivations () |
virtual std::vector < std::shared_ptr < mic::types::Matrix< eT > > > & | getOutputGradientActivations () |
Private Member Functions | |
Linear () | |
Private Attributes | |
std::vector < mic::types::MatrixPtr< eT > > | w_activations |
Vector containing activations of weights/filters. More... | |
std::vector < mic::types::MatrixPtr< eT > > | dw_activations |
Vector containing activations of gradients of weights (dW). More... | |
std::vector < mic::types::MatrixPtr< eT > > | inverse_w_activations |
Vector containing "inverse activations" of each neuron weights(W^T). More... | |
std::vector < mic::types::MatrixPtr< eT > > | inverse_y_activations |
Vector containing activations of neurons (y*W^T). More... | |
Friends | |
template<typename tmp > | |
class | mic::mlnn::MultiLayerNeuralNetwork |
template<typename tmp > | |
class | mic::mlnn::fully_connected::SparseLinear |
Additional Inherited Members | |
![]() | |
Layer () | |
![]() | |
size_t | input_height |
Height of the input (e.g. 28 for MNIST). More... | |
size_t | input_width |
Width of the input (e.g. 28 for MNIST). More... | |
size_t | input_depth |
Number of channels of the input (e.g. 3 for RGB images). More... | |
size_t | output_height |
Number of receptive fields in a single channel - vertical direction. More... | |
size_t | output_width |
Number of receptive fields in a single channel - horizontal direction. More... | |
size_t | output_depth |
Number of filters = number of output channels. More... | |
size_t | batch_size |
Size (length) of (mini)batch. More... | |
LayerTypes | layer_type |
Type of the layer. More... | |
std::string | layer_name |
Name (identifier of the type) of the layer. More... | |
mic::types::MatrixArray< eT > | s |
States - contains input [x] and output [y] matrices. More... | |
mic::types::MatrixArray< eT > | g |
Gradients - contains input [x] and output [y] matrices. More... | |
mic::types::MatrixArray< eT > | p |
Parameters - parameters of the layer, to be used by the derived classes. More... | |
mic::types::MatrixArray< eT > | m |
Memory - a list of temporal parameters, to be used by the derived classes. More... | |
mic::neural_nets::optimization::OptimizationArray < eT > | opt |
Array of optimization functions. More... | |
std::vector< std::shared_ptr < mic::types::Matrix< eT > > > | x_activations |
Vector containing activations of input neurons - used in visualization. More... | |
std::vector< std::shared_ptr < mic::types::Matrix< eT > > > | dx_activations |
Vector containing activations of gradients of inputs (dx) - used in visualization. More... | |
std::vector< std::shared_ptr < mic::types::Matrix< eT > > > | y_activations |
Vector containing activations of output neurons - used in visualization. More... | |
std::vector< std::shared_ptr < mic::types::Matrix< eT > > > | dy_activations |
Vector containing activations of gradients of outputs (dy) - used in visualization. More... | |
Class implementing a linear, fully connected layer.
eT | Template parameter denoting precision of variables (float for calculations/double for testing). |
Definition at line 42 of file Linear.hpp.
|
inline |
Creates a linear (i.e fully connected) layer - reduced number of parameters.
inputs_ | Length of the input vector. |
outputs_ | Length of the output vector. |
name_ | Name of the layer. |
Definition at line 51 of file Linear.hpp.
|
inline |
Creates a linear (i.e fully connected) layer.
input_height_ | Height of the input sample. |
input_width_ | Width of the input sample. |
input_depth_ | Depth of the input sample. |
output_height_ | Width of the output sample. |
output_width_ | Height of the output sample. |
output_depth_ | Depth of the output sample. |
name_ | Name of the layer. |
Definition at line 68 of file Linear.hpp.
|
inlinevirtual |
Virtual destructor - empty.
Definition at line 99 of file Linear.hpp.
|
inlineprivate |
Private constructor, used only during the serialization.
Definition at line 367 of file Linear.hpp.
|
inlinevirtual |
Backward pass.
Implements mic::mlnn::Layer< eT >.
Reimplemented in mic::mlnn::fully_connected::SparseLinear< eT >.
Definition at line 126 of file Linear.hpp.
Referenced by mic::neural_nets::unit_tests::TEST().
|
inline |
Calculates mean reconstruction error (mean of all RMS errors between input and reconstructed samples).
Definition at line 289 of file Linear.hpp.
|
inlinevirtual |
Forward pass.
test_ | It ise set to true in test mode (network verification). |
Implements mic::mlnn::Layer< eT >.
Definition at line 105 of file Linear.hpp.
Referenced by mic::neural_nets::unit_tests::TEST().
|
inline |
Returns inverse activations of output neurons (y*W^T) - reconstruction of the input.
Definition at line 249 of file Linear.hpp.
Referenced by mic::mlnn::fully_connected::Linear< float >::calculateMeanReconstructionError().
|
inline |
Returns "inverse activations" of each neuron weights (W^T) - shows what activates given neuron.
Definition at line 219 of file Linear.hpp.
|
inline |
Returns activations of weights.
Definition at line 173 of file Linear.hpp.
|
inline |
Returns activations of weight gradients (dx).
Definition at line 196 of file Linear.hpp.
|
inlinevirtual |
Resets the gradients for W and b.
Reimplemented from mic::mlnn::Layer< eT >.
Definition at line 148 of file Linear.hpp.
|
inlinevirtual |
Applies the gradient update, using the selected optimization method.
alpha_ | Learning rate - passed to the optimization functions of all layers. |
decay_ | Weight decay rate (determining that the "unused/unupdated" weights will decay to 0) (DEFAULT=0.0 - no decay). |
Implements mic::mlnn::Layer< eT >.
Reimplemented in mic::mlnn::fully_connected::SparseLinear< eT >.
Definition at line 159 of file Linear.hpp.
|
friend |
Definition at line 350 of file Linear.hpp.
|
friend |
Definition at line 347 of file Linear.hpp.
|
private |
Vector containing activations of gradients of weights (dW).
Definition at line 356 of file Linear.hpp.
Referenced by mic::mlnn::fully_connected::Linear< float >::getWeightGradientActivations().
|
private |
Vector containing "inverse activations" of each neuron weights(W^T).
Definition at line 359 of file Linear.hpp.
Referenced by mic::mlnn::fully_connected::Linear< float >::getInverseWeightActivations().
|
private |
Vector containing activations of neurons (y*W^T).
Definition at line 362 of file Linear.hpp.
Referenced by mic::mlnn::fully_connected::Linear< float >::getInverseOutputActivations().
|
private |
Vector containing activations of weights/filters.
Definition at line 353 of file Linear.hpp.
Referenced by mic::mlnn::fully_connected::Linear< float >::getWeightActivations().