BlackCat_Tensors
A GPU-supported autograd and linear algebra library, designed for neural network construction
Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Attributes | List of all members
bc::nn::Layer_Base< DerivedLayer, InputTensorDescriptor, OutputTensorDescriptor > Struct Template Reference

#include <layer_base.h>

Inheritance diagram for bc::nn::Layer_Base< DerivedLayer, InputTensorDescriptor, OutputTensorDescriptor >:
Inheritance graph
[legend]
Collaboration diagram for bc::nn::Layer_Base< DerivedLayer, InputTensorDescriptor, OutputTensorDescriptor >:
Collaboration graph
[legend]

Public Types

using value_type = typename InputTensorDescriptor::value_type
 
using system_tag = typename InputTensorDescriptor::system_tag
 
using allocator_type = typename InputTensorDescriptor::allocator_type
 
using input_tensor_dim = typename InputTensorDescriptor::tensor_dim
 
using shape_type = bc::Dim< input_tensor_dim::value >
 
using input_tensor_type = typename InputTensorDescriptor::type
 
using batched_input_tensor_type = typename InputTensorDescriptor::batched_type
 
using output_value_type = typename OutputTensorDescriptor::value_type
 
using output_system_tag = typename OutputTensorDescriptor::system_tag
 
using output_allocator_type = typename OutputTensorDescriptor::allocator_type
 
using output_tensor_dim = typename OutputTensorDescriptor::tensor_dim
 
using output_shape_type = bc::Dim< output_tensor_dim::value >
 
using output_tensor_type = typename OutputTensorDescriptor::type
 
using batched_output_tensor_type = typename OutputTensorDescriptor::batched_type
 
- Public Types inherited from bc::nn::Layer_Output_Base< OutputTensorDescriptor >
using output_value_type = typename OutputTensorDescriptor::value_type
 
using output_system_tag = typename OutputTensorDescriptor::system_tag
 
using output_allocator_type = typename OutputTensorDescriptor::allocator_type
 
using output_tensor_dim = typename OutputTensorDescriptor::tensor_dim
 
using output_shape_type = bc::Dim< output_tensor_dim::value >
 
using output_tensor_type = typename OutputTensorDescriptor::type
 
using batched_output_tensor_type = typename OutputTensorDescriptor::batched_type
 
using next_layer_type = Layer_Input_Base< OutputTensorDescriptor >
 
using output_value_type = typename OutputTensorDescriptor::value_type
 
using output_system_tag = typename OutputTensorDescriptor::system_tag
 
using output_allocator_type = typename OutputTensorDescriptor::allocator_type
 
using output_tensor_dim = typename OutputTensorDescriptor::tensor_dim
 
using output_shape_type = typename OutputTensorDescriptor::shape_type
 
using output_tensor_type = typename OutputTensorDescriptor::tensor_type
 
using batched_output_tensor_type = typename OutputTensorDescriptor::batched_type
 
using next_layer_type = Layer_Input_Base< OutputTensorDescriptor >
 

Public Member Functions

 Layer_Base (std::string classname, shape_type input_shape, output_shape_type output_shape)
 m_classname should be initialized by supplying __func__ to the first argument of the Layer_Base. More...
 
 Layer_Base (std::string classname, shape_type input_shape)
 
virtual ~Layer_Base ()
 
virtual output_shape_type get_output_shape () const
 
virtual shape_type get_input_shape () const
 
auto get_batched_input_shape () const
 
auto get_batched_output_shape () const
 
bc::size_t input_size () const
 
bc::size_t output_size () const
 
bc::size_t batch_size () const
 
bc::size_t batched_input_size () const
 
bc::size_t batched_output_size () const
 
void set_batch_size (int batch_size)
 
virtual void set_batch_size_hook (int batch_size)
 
void set_learning_rate (value_type learning_rate)
 
virtual void set_learning_rate_hook (value_type learning_rate)
 
auto get_learning_rate () const
 
auto get_batched_learning_rate () const
 
virtual void save (Layer_Loader &) const
 
virtual void save_from_cache (Layer_Loader &, const Cache &) const
 
virtual void load (Layer_Loader &)
 
virtual void load_to_cache (Layer_Loader &, const Cache &)
 
void copy_training_data_to_single_predict (Cache &, int batch_index)
 
void update_weights ()
 
void clear_bp_storage (Cache &)
 
const std::string & classname () const
 Returns the derived_classes class namepse. More...
 
template<int ADL = 0>
std::string get_string_architecture () const
 
virtual std::string get_string_architecture_hook () const
 
auto default_input_tensor_factory () const
 
auto default_output_tensor_factory () const
 
auto default_batched_input_tensor_factory () const
 
auto default_batched_output_tensor_factory () const
 
- Public Member Functions inherited from bc::nn::Layer_Input_Base< InputTensorDescriptor >
void set_prev (prev_layer_type &prev)
 
input_shape_type input_shape () const
 
const prev_layer_typeprev_layer () const
 
prev_layer_typeprev_layer ()
 
virtual ~Layer_Input_Base ()
 
void set_prev (prev_layer_type &prev)
 
input_shape_type input_shape () const
 
const prev_layer_typeprev_layer () const
 
prev_layer_typeprev_layer ()
 
virtual ~Layer_Input_Base ()
 
- Public Member Functions inherited from bc::nn::Layer_Output_Base< OutputTensorDescriptor >
void set_next (next_layer_type &next)
 
output_shape_type output_shape () const
 
const next_layer_typenext_layer () const
 
next_layer_typenext_layer ()
 
virtual ~Layer_Output_Base ()
 
void set_next (next_layer_type &next)
 
output_shape_type output_shape () const
 
const next_layer_typenext_layer () const
 
next_layer_typenext_layer ()
 
virtual ~Layer_Output_Base ()
 

Static Public Member Functions

static std::string parse_classname (std::string classname)
 

Static Public Attributes

static constexpr value_type default_learning_rate = .01
 

Protected Attributes

shape_type m_input_shape
 
output_shape_type m_output_shape
 
- Protected Attributes inherited from bc::nn::Layer_Input_Base< InputTensorDescriptor >
prev_layer_typem_prev_layer
 
input_shape_type m_input_shape
 
- Protected Attributes inherited from bc::nn::Layer_Output_Base< OutputTensorDescriptor >
next_layer_typem_next_layer = nullptr
 
bc::Dim< output_tensor_dim::value > m_output_shape
 

Member Typedef Documentation

◆ allocator_type

template<class DerivedLayer, class InputTensorDescriptor, class OutputTensorDescriptor = InputTensorDescriptor>
using bc::nn::Layer_Base< DerivedLayer, InputTensorDescriptor, OutputTensorDescriptor >::allocator_type = typename InputTensorDescriptor::allocator_type

◆ batched_input_tensor_type

template<class DerivedLayer, class InputTensorDescriptor, class OutputTensorDescriptor = InputTensorDescriptor>
using bc::nn::Layer_Base< DerivedLayer, InputTensorDescriptor, OutputTensorDescriptor >::batched_input_tensor_type = typename InputTensorDescriptor::batched_type

◆ batched_output_tensor_type

template<class DerivedLayer, class InputTensorDescriptor, class OutputTensorDescriptor = InputTensorDescriptor>
using bc::nn::Layer_Base< DerivedLayer, InputTensorDescriptor, OutputTensorDescriptor >::batched_output_tensor_type = typename OutputTensorDescriptor::batched_type

◆ input_tensor_dim

template<class DerivedLayer, class InputTensorDescriptor, class OutputTensorDescriptor = InputTensorDescriptor>
using bc::nn::Layer_Base< DerivedLayer, InputTensorDescriptor, OutputTensorDescriptor >::input_tensor_dim = typename InputTensorDescriptor::tensor_dim

◆ input_tensor_type

template<class DerivedLayer, class InputTensorDescriptor, class OutputTensorDescriptor = InputTensorDescriptor>
using bc::nn::Layer_Base< DerivedLayer, InputTensorDescriptor, OutputTensorDescriptor >::input_tensor_type = typename InputTensorDescriptor::type

◆ output_allocator_type

template<class DerivedLayer, class InputTensorDescriptor, class OutputTensorDescriptor = InputTensorDescriptor>
using bc::nn::Layer_Base< DerivedLayer, InputTensorDescriptor, OutputTensorDescriptor >::output_allocator_type = typename OutputTensorDescriptor::allocator_type

◆ output_shape_type

template<class DerivedLayer, class InputTensorDescriptor, class OutputTensorDescriptor = InputTensorDescriptor>
using bc::nn::Layer_Base< DerivedLayer, InputTensorDescriptor, OutputTensorDescriptor >::output_shape_type = bc::Dim<output_tensor_dim::value>

◆ output_system_tag

template<class DerivedLayer, class InputTensorDescriptor, class OutputTensorDescriptor = InputTensorDescriptor>
using bc::nn::Layer_Base< DerivedLayer, InputTensorDescriptor, OutputTensorDescriptor >::output_system_tag = typename OutputTensorDescriptor::system_tag

◆ output_tensor_dim

template<class DerivedLayer, class InputTensorDescriptor, class OutputTensorDescriptor = InputTensorDescriptor>
using bc::nn::Layer_Base< DerivedLayer, InputTensorDescriptor, OutputTensorDescriptor >::output_tensor_dim = typename OutputTensorDescriptor::tensor_dim

◆ output_tensor_type

template<class DerivedLayer, class InputTensorDescriptor, class OutputTensorDescriptor = InputTensorDescriptor>
using bc::nn::Layer_Base< DerivedLayer, InputTensorDescriptor, OutputTensorDescriptor >::output_tensor_type = typename OutputTensorDescriptor::type

◆ output_value_type

template<class DerivedLayer, class InputTensorDescriptor, class OutputTensorDescriptor = InputTensorDescriptor>
using bc::nn::Layer_Base< DerivedLayer, InputTensorDescriptor, OutputTensorDescriptor >::output_value_type = typename OutputTensorDescriptor::value_type

◆ shape_type

template<class DerivedLayer, class InputTensorDescriptor, class OutputTensorDescriptor = InputTensorDescriptor>
using bc::nn::Layer_Base< DerivedLayer, InputTensorDescriptor, OutputTensorDescriptor >::shape_type = bc::Dim<input_tensor_dim::value>

◆ system_tag

template<class DerivedLayer, class InputTensorDescriptor, class OutputTensorDescriptor = InputTensorDescriptor>
using bc::nn::Layer_Base< DerivedLayer, InputTensorDescriptor, OutputTensorDescriptor >::system_tag = typename InputTensorDescriptor::system_tag

◆ value_type

template<class DerivedLayer, class InputTensorDescriptor, class OutputTensorDescriptor = InputTensorDescriptor>
using bc::nn::Layer_Base< DerivedLayer, InputTensorDescriptor, OutputTensorDescriptor >::value_type = typename InputTensorDescriptor::value_type

Constructor & Destructor Documentation

◆ Layer_Base() [1/2]

template<class DerivedLayer, class InputTensorDescriptor, class OutputTensorDescriptor = InputTensorDescriptor>
bc::nn::Layer_Base< DerivedLayer, InputTensorDescriptor, OutputTensorDescriptor >::Layer_Base ( std::string  classname,
shape_type  input_shape,
output_shape_type  output_shape 
)
inline

m_classname should be initialized by supplying __func__ to the first argument of the Layer_Base.

parse_classname() will normalize the string as __func__ is compiler dependent.

◆ Layer_Base() [2/2]

template<class DerivedLayer, class InputTensorDescriptor, class OutputTensorDescriptor = InputTensorDescriptor>
bc::nn::Layer_Base< DerivedLayer, InputTensorDescriptor, OutputTensorDescriptor >::Layer_Base ( std::string  classname,
shape_type  input_shape 
)
inline

◆ ~Layer_Base()

template<class DerivedLayer, class InputTensorDescriptor, class OutputTensorDescriptor = InputTensorDescriptor>
virtual bc::nn::Layer_Base< DerivedLayer, InputTensorDescriptor, OutputTensorDescriptor >::~Layer_Base ( )
inlinevirtual

Member Function Documentation

◆ batch_size()

template<class DerivedLayer, class InputTensorDescriptor, class OutputTensorDescriptor = InputTensorDescriptor>
bc::size_t bc::nn::Layer_Base< DerivedLayer, InputTensorDescriptor, OutputTensorDescriptor >::batch_size ( ) const
inline

◆ batched_input_size()

template<class DerivedLayer, class InputTensorDescriptor, class OutputTensorDescriptor = InputTensorDescriptor>
bc::size_t bc::nn::Layer_Base< DerivedLayer, InputTensorDescriptor, OutputTensorDescriptor >::batched_input_size ( ) const
inline

◆ batched_output_size()

template<class DerivedLayer, class InputTensorDescriptor, class OutputTensorDescriptor = InputTensorDescriptor>
bc::size_t bc::nn::Layer_Base< DerivedLayer, InputTensorDescriptor, OutputTensorDescriptor >::batched_output_size ( ) const
inline

◆ classname()

template<class DerivedLayer, class InputTensorDescriptor, class OutputTensorDescriptor = InputTensorDescriptor>
const std::string& bc::nn::Layer_Base< DerivedLayer, InputTensorDescriptor, OutputTensorDescriptor >::classname ( ) const
inline

Returns the derived_classes class namepse.

Note: Architecture dependent

◆ clear_bp_storage()

template<class DerivedLayer, class InputTensorDescriptor, class OutputTensorDescriptor = InputTensorDescriptor>
void bc::nn::Layer_Base< DerivedLayer, InputTensorDescriptor, OutputTensorDescriptor >::clear_bp_storage ( Cache )
inline

◆ copy_training_data_to_single_predict()

template<class DerivedLayer, class InputTensorDescriptor, class OutputTensorDescriptor = InputTensorDescriptor>
void bc::nn::Layer_Base< DerivedLayer, InputTensorDescriptor, OutputTensorDescriptor >::copy_training_data_to_single_predict ( Cache ,
int  batch_index 
)
inline

◆ default_batched_input_tensor_factory()

template<class DerivedLayer, class InputTensorDescriptor, class OutputTensorDescriptor = InputTensorDescriptor>
auto bc::nn::Layer_Base< DerivedLayer, InputTensorDescriptor, OutputTensorDescriptor >::default_batched_input_tensor_factory ( ) const
inline

◆ default_batched_output_tensor_factory()

template<class DerivedLayer, class InputTensorDescriptor, class OutputTensorDescriptor = InputTensorDescriptor>
auto bc::nn::Layer_Base< DerivedLayer, InputTensorDescriptor, OutputTensorDescriptor >::default_batched_output_tensor_factory ( ) const
inline

◆ default_input_tensor_factory()

template<class DerivedLayer, class InputTensorDescriptor, class OutputTensorDescriptor = InputTensorDescriptor>
auto bc::nn::Layer_Base< DerivedLayer, InputTensorDescriptor, OutputTensorDescriptor >::default_input_tensor_factory ( ) const
inline

◆ default_output_tensor_factory()

template<class DerivedLayer, class InputTensorDescriptor, class OutputTensorDescriptor = InputTensorDescriptor>
auto bc::nn::Layer_Base< DerivedLayer, InputTensorDescriptor, OutputTensorDescriptor >::default_output_tensor_factory ( ) const
inline

◆ get_batched_input_shape()

template<class DerivedLayer, class InputTensorDescriptor, class OutputTensorDescriptor = InputTensorDescriptor>
auto bc::nn::Layer_Base< DerivedLayer, InputTensorDescriptor, OutputTensorDescriptor >::get_batched_input_shape ( ) const
inline

◆ get_batched_learning_rate()

template<class DerivedLayer, class InputTensorDescriptor, class OutputTensorDescriptor = InputTensorDescriptor>
auto bc::nn::Layer_Base< DerivedLayer, InputTensorDescriptor, OutputTensorDescriptor >::get_batched_learning_rate ( ) const
inline

◆ get_batched_output_shape()

template<class DerivedLayer, class InputTensorDescriptor, class OutputTensorDescriptor = InputTensorDescriptor>
auto bc::nn::Layer_Base< DerivedLayer, InputTensorDescriptor, OutputTensorDescriptor >::get_batched_output_shape ( ) const
inline

◆ get_input_shape()

template<class DerivedLayer, class InputTensorDescriptor, class OutputTensorDescriptor = InputTensorDescriptor>
virtual shape_type bc::nn::Layer_Base< DerivedLayer, InputTensorDescriptor, OutputTensorDescriptor >::get_input_shape ( ) const
inlinevirtual

◆ get_learning_rate()

template<class DerivedLayer, class InputTensorDescriptor, class OutputTensorDescriptor = InputTensorDescriptor>
auto bc::nn::Layer_Base< DerivedLayer, InputTensorDescriptor, OutputTensorDescriptor >::get_learning_rate ( ) const
inline

◆ get_output_shape()

template<class DerivedLayer, class InputTensorDescriptor, class OutputTensorDescriptor = InputTensorDescriptor>
virtual output_shape_type bc::nn::Layer_Base< DerivedLayer, InputTensorDescriptor, OutputTensorDescriptor >::get_output_shape ( ) const
inlinevirtual

◆ get_string_architecture()

template<class DerivedLayer, class InputTensorDescriptor, class OutputTensorDescriptor = InputTensorDescriptor>
template<int ADL = 0>
std::string bc::nn::Layer_Base< DerivedLayer, InputTensorDescriptor, OutputTensorDescriptor >::get_string_architecture ( ) const
inline

◆ get_string_architecture_hook()

template<class DerivedLayer, class InputTensorDescriptor, class OutputTensorDescriptor = InputTensorDescriptor>
virtual std::string bc::nn::Layer_Base< DerivedLayer, InputTensorDescriptor, OutputTensorDescriptor >::get_string_architecture_hook ( ) const
inlinevirtual

◆ input_size()

template<class DerivedLayer, class InputTensorDescriptor, class OutputTensorDescriptor = InputTensorDescriptor>
bc::size_t bc::nn::Layer_Base< DerivedLayer, InputTensorDescriptor, OutputTensorDescriptor >::input_size ( ) const
inline

◆ load()

template<class DerivedLayer, class InputTensorDescriptor, class OutputTensorDescriptor = InputTensorDescriptor>
virtual void bc::nn::Layer_Base< DerivedLayer, InputTensorDescriptor, OutputTensorDescriptor >::load ( Layer_Loader )
inlinevirtual

◆ load_to_cache()

template<class DerivedLayer, class InputTensorDescriptor, class OutputTensorDescriptor = InputTensorDescriptor>
virtual void bc::nn::Layer_Base< DerivedLayer, InputTensorDescriptor, OutputTensorDescriptor >::load_to_cache ( Layer_Loader ,
const Cache  
)
inlinevirtual

◆ output_size()

template<class DerivedLayer, class InputTensorDescriptor, class OutputTensorDescriptor = InputTensorDescriptor>
bc::size_t bc::nn::Layer_Base< DerivedLayer, InputTensorDescriptor, OutputTensorDescriptor >::output_size ( ) const
inline

◆ parse_classname()

template<class DerivedLayer, class InputTensorDescriptor, class OutputTensorDescriptor = InputTensorDescriptor>
static std::string bc::nn::Layer_Base< DerivedLayer, InputTensorDescriptor, OutputTensorDescriptor >::parse_classname ( std::string  classname)
inlinestatic

◆ save()

template<class DerivedLayer, class InputTensorDescriptor, class OutputTensorDescriptor = InputTensorDescriptor>
virtual void bc::nn::Layer_Base< DerivedLayer, InputTensorDescriptor, OutputTensorDescriptor >::save ( Layer_Loader ) const
inlinevirtual

◆ save_from_cache()

template<class DerivedLayer, class InputTensorDescriptor, class OutputTensorDescriptor = InputTensorDescriptor>
virtual void bc::nn::Layer_Base< DerivedLayer, InputTensorDescriptor, OutputTensorDescriptor >::save_from_cache ( Layer_Loader ,
const Cache  
) const
inlinevirtual

◆ set_batch_size()

template<class DerivedLayer, class InputTensorDescriptor, class OutputTensorDescriptor = InputTensorDescriptor>
void bc::nn::Layer_Base< DerivedLayer, InputTensorDescriptor, OutputTensorDescriptor >::set_batch_size ( int  batch_size)
inline

◆ set_batch_size_hook()

template<class DerivedLayer, class InputTensorDescriptor, class OutputTensorDescriptor = InputTensorDescriptor>
virtual void bc::nn::Layer_Base< DerivedLayer, InputTensorDescriptor, OutputTensorDescriptor >::set_batch_size_hook ( int  batch_size)
inlinevirtual

◆ set_learning_rate()

template<class DerivedLayer, class InputTensorDescriptor, class OutputTensorDescriptor = InputTensorDescriptor>
void bc::nn::Layer_Base< DerivedLayer, InputTensorDescriptor, OutputTensorDescriptor >::set_learning_rate ( value_type  learning_rate)
inline

◆ set_learning_rate_hook()

template<class DerivedLayer, class InputTensorDescriptor, class OutputTensorDescriptor = InputTensorDescriptor>
virtual void bc::nn::Layer_Base< DerivedLayer, InputTensorDescriptor, OutputTensorDescriptor >::set_learning_rate_hook ( value_type  learning_rate)
inlinevirtual

◆ update_weights()

template<class DerivedLayer, class InputTensorDescriptor, class OutputTensorDescriptor = InputTensorDescriptor>
void bc::nn::Layer_Base< DerivedLayer, InputTensorDescriptor, OutputTensorDescriptor >::update_weights ( )
inline

Member Data Documentation

◆ default_learning_rate

template<class DerivedLayer, class InputTensorDescriptor, class OutputTensorDescriptor = InputTensorDescriptor>
constexpr value_type bc::nn::Layer_Base< DerivedLayer, InputTensorDescriptor, OutputTensorDescriptor >::default_learning_rate = .01
static

◆ m_input_shape

template<class DerivedLayer, class InputTensorDescriptor, class OutputTensorDescriptor = InputTensorDescriptor>
shape_type bc::nn::Layer_Base< DerivedLayer, InputTensorDescriptor, OutputTensorDescriptor >::m_input_shape
protected

◆ m_output_shape

template<class DerivedLayer, class InputTensorDescriptor, class OutputTensorDescriptor = InputTensorDescriptor>
output_shape_type bc::nn::Layer_Base< DerivedLayer, InputTensorDescriptor, OutputTensorDescriptor >::m_output_shape
protected

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