shark::Shape Class Reference

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. More...
 
template<class Archive >
void serialize (Archive &archive, unsigned int version)
 

Detailed Description

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 descriebs 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.

Definition at line 67 of file Shape.h.

Constructor & Destructor Documentation

◆ Shape() [1/3]

shark::Shape::Shape ( )
inline

Definition at line 69 of file Shape.h.

Referenced by flatten().

◆ Shape() [2/3]

shark::Shape::Shape ( std::size_t  size)
inline

Definition at line 70 of file Shape.h.

◆ Shape() [3/3]

shark::Shape::Shape ( std::initializer_list< std::size_t >  dims)
inline

Definition at line 71 of file Shape.h.

Member Function Documentation

◆ flatten()

Shape shark::Shape::flatten ( ) const
inline

Returns a 1-D shape with the same number of elements.

Definition at line 88 of file Shape.h.

References Shape().

◆ numElements()

◆ operator[]()

std::size_t shark::Shape::operator[] ( std::size_t  i) const
inline

Definition at line 80 of file Shape.h.

◆ serialize()

template<class Archive >
void shark::Shape::serialize ( Archive &  archive,
unsigned int  version 
)
inline

Definition at line 93 of file Shape.h.

◆ size()

std::size_t shark::Shape::size ( ) const
inline

Definition at line 77 of file Shape.h.

Referenced by shark::operator==().


The documentation for this class was generated from the following file: