![]() |
ceras
yet another deep learning engine
|
#include <tensor.hpp>
Public Member Functions | |
| constexpr | view_4d (T *data=nullptr, unsigned long batch_size=0, unsigned long row=0, unsigned long col=0, unsigned long channel=0) noexcept |
| constexpr auto | operator[] (unsigned long index) noexcept |
| constexpr auto | operator[] (unsigned long index) const noexcept |
Public Attributes | |
| T * | data_ |
| The pointer to the start position of the 1-D array. More... | |
| unsigned long | batch_size_ |
| The batch size of the 4-D tensor, also the first dimension of the tensor. More... | |
| unsigned long | row_ |
| The row of the 4-D tensor, also the second dimension of the tensor. More... | |
| unsigned long | col_ |
| The column of the 4-D tensor, also the third dimension of the tensor. More... | |
| unsigned long | channel_ |
| The channel of the 4-D tensor, also the last dimension of the tensor. More... | |
A class viewing a 1-D array as a 4-D tensor. This class is useful when treating an array as a typical 4-D tensor in a neural network, with a shape of [batch_size, row, column, channel].
|
inlineconstexprnoexcept |
Constructor of view_4d
| data | The raw pointer to the start position of the 1-D array. |
| batch_size | The first dimension of the 4-D tensor, also for the batch size in the CNN layers. |
| row | The second dimension of the 4-D tensor, also for the row in the CNN layers. |
| col | The third dimension of the 4-D tensor, also for the column in the CNN layers. |
| channel | The last dimension of the 4-D tensor, also for the channel in the CNN layers. |
|
inlineconstexprnoexcept |
Giving a view_3d interface for operator [].
| index | The first dimension of the 4-D tensor. |
Example usage:
|
inlineconstexprnoexcept |
| unsigned long ceras::view_4d< T >::batch_size_ |
The batch size of the 4-D tensor, also the first dimension of the tensor.
| unsigned long ceras::view_4d< T >::channel_ |
The channel of the 4-D tensor, also the last dimension of the tensor.
| unsigned long ceras::view_4d< T >::col_ |
The column of the 4-D tensor, also the third dimension of the tensor.
| T* ceras::view_4d< T >::data_ |
The pointer to the start position of the 1-D array.
| unsigned long ceras::view_4d< T >::row_ |
The row of the 4-D tensor, also the second dimension of the tensor.