Represents the Shape of an input or output. More...
#include <shark/Core/Shape.h>
Public Member Functions | |
Shape () | |
Shape (std::size_t size) | |
Shape (std::initializer_list< std::size_t > dims) | |
std::size_t | size () const |
std::size_t | operator[] (std::size_t i) const |
std::size_t | numElements () const |
Shape | flatten () const |
Returns a 1-D shape with the same number of elements. | |
std::size_t | stride (std::size_t dim) const |
template<class Archive > | |
void | serialize (Archive &archive, unsigned int version) |
Represents the Shape of an input or output.
Mostly used for vector data, the Shape describes The expected structure of a model. A N-D shape with shape variables (n1,n2,..nN) expects an input of size n1*n2*...*nN which is then interpreted as tensor with the dimensionalities n1 x n2 x ... x nN. A batch of inputs is then treated as each element having this shape, so the batch size is not a part of the shape.
The standard shape is the 1-D shape just describing that a model interprets every input as 1-D input. A 0-D shape describes the inputs of a model where the input can not be described by a shape, for example a class label or other scalar values are 0d shapes. A 3-D shape could describe an image patch with rows x columns x channels.
Shapes can be flattened, this way a 3-D image patch can also be treated as a simple vector input.
Shark currently does not enforce Shapes, it only checks that input data is compatible to a shape, i.e. a vector has the right number of dimensions.
|
inline |
|
inline |
|
inline |
Definition at line 83 of file Shape.h.
Referenced by shark::NeuronLayer< NeuronType, VectorType >::eval(), shark::ResizeLayer< VectorType >::eval(), shark::Conv2DModel< VectorType, ActivationFunction >::eval(), shark::NeuronLayer< NeuronType, VectorType >::eval(), shark::PoolingLayer< VectorType >::eval(), shark::NeuronLayer< NeuronType, VectorType >::eval(), shark::LinearModel< InputType, ActivationFunction >::setParameterVector(), shark::PCA::train(), shark::LinearModel< InputType, ActivationFunction >::weightedDerivatives(), shark::ResizeLayer< VectorType >::weightedInputDerivative(), and shark::LinearModel< InputType, ActivationFunction >::weightedParameterDerivative().
|
inline |
|
inline |
|
inline |
Definition at line 77 of file Shape.h.
Referenced by shark::Normalizer< VectorType >::inputShape(), shark::operator==(), shark::Normalizer< VectorType >::outputShape(), shark::image::reorder(), and stride().
|
inline |