RTNeural  1.0.0
Real-time neural inferencing library
Functions
RTNEURAL_NAMESPACE::json_parser Namespace Reference

Utility functions for loading model weights from their json representation. More...

Functions

template<typename T , typename DenseType >
void loadDense (DenseType &dense, const nlohmann::json &weights)
 Loads weights for a Dense (or DenseT) layer from a json representation of the layer weights. More...
 
template<typename T >
std::unique_ptr< Dense< T > > createDense (int in_size, int out_size, const nlohmann::json &weights)
 Creates a Dense layer from a json representation of the layer weights. More...
 
template<typename T , typename DenseType >
bool checkDense (const DenseType &dense, const std::string &type, int layerDims, const bool debug)
 Checks that a Dense (or DenseT) layer has the given dimensions. More...
 
template<typename T , typename Conv1DType >
void loadConv1D (Conv1DType &conv, int kernel_size, int, const nlohmann::json &weights)
 Loads weights for a Conv1D (or Conv1DT) layer from a json representation of the layer weights. More...
 
template<typename T , typename Conv2DType >
void loadConv2D (Conv2DType &conv2d, const nlohmann::json &weights)
 Loads weights for a Conv2D (or Conv2DT) layer from a json representation of the layer weights. More...
 
template<typename T >
std::unique_ptr< Conv1D< T > > createConv1D (int in_size, int out_size, int kernel_size, int dilation, int groups, const nlohmann::json &weights)
 Creates a Conv1D layer from a json representation of the layer weights. More...
 
template<typename T , typename Conv1DType >
bool checkConv1D (const Conv1DType &conv, const std::string &type, int layerDims, int kernel_size, int dilation_rate, int groups, const bool debug)
 Checks that a Conv1D (or Conv1DT) layer has the given dimensions. More...
 
template<typename T >
std::unique_ptr< Conv2D< T > > createConv2D (int num_filters_in, int num_features_in, int num_filters_out, int kernel_size_time, int kernel_size_feature, int dilation, int stride, bool valid_pad, const nlohmann::json &weights)
 
template<typename T , typename Conv2DType >
bool checkConv2D (const Conv2DType &conv, const std::string &type, int layerDims, int kernel_size_time, int kernel_size_feature, int dilation_rate, int stride, bool, const bool debug)
 Checks that a Conv2D (or Conv2DT) layer has the given dimensions. More...
 
template<typename T , typename GRUType >
void loadGRU (GRUType &gru, const nlohmann::json &weights)
 Loads weights for a GRULayer (or GRULayerT) from a json representation of the layer weights. More...
 
template<typename T >
std::unique_ptr< GRULayer< T > > createGRU (int in_size, int out_size, const nlohmann::json &weights)
 Creates a GRULayer from a json representation of the layer weights. More...
 
template<typename T , typename GRUType >
bool checkGRU (const GRUType &gru, const std::string &type, int layerDims, const bool debug)
 Checks that a GRULayer (or GRULayerT) has the given dimensions. More...
 
template<typename T , typename LSTMType >
void loadLSTM (LSTMType &lstm, const nlohmann::json &weights)
 Loads weights for a LSTMLayer (or LSTMLayerT) from a json representation of the layer weights. More...
 
template<typename T >
std::unique_ptr< LSTMLayer< T > > createLSTM (int in_size, int out_size, const nlohmann::json &weights)
 Creates a LSTMLayer from a json representation of the layer weights. More...
 
template<typename T , typename LSTMType >
bool checkLSTM (const LSTMType &lstm, const std::string &type, int layerDims, const bool debug)
 Checks that a LSTMLayer (or LSTMLayerT) has the given dimensions. More...
 
template<typename T , typename PReLUType >
void loadPReLU (PReLUType &prelu, const nlohmann::json &weights)
 Loads weights for a PReLUActivation (or PReLUActivationT) from a json representation of the layer weights. More...
 
template<typename T >
std::unique_ptr< PReLUActivation< T > > createPReLU (int in_size, const nlohmann::json &weights)
 Creates a PReLUActivation from a json representation of the layer weights. More...
 
template<typename T , typename PReLUType >
bool checkPReLU (const PReLUType &prelu, const std::string &type, int layerDims, const bool debug)
 Checks that a PReLUActivation (or PReLUActivationT) has the given dimensions. More...
 
template<typename T , typename BatchNormType >
void loadBatchNorm (BatchNormType &batch_norm, const nlohmann::json &weights, bool affine)
 Loads weights for a BatchNorm1DLayer (or BatchNorm1DT) or BatchNorm2DLayer (or BatchNorm2DT) from a json representation of the layer weights. More...
 
template<typename T , typename BatchNormType >
void loadBatchNorm (BatchNormType &batch_norm, const nlohmann::json &weights)
 Loads weights for a BatchNorm1DLayer (or BatchNorm1DT) from a json representation of the layer weights. More...
 
template<typename T >
std::unique_ptr< BatchNorm1DLayer< T > > createBatchNorm (int size, const nlohmann::json &weights, T epsilon)
 Creates a BatchNorm1DLayer from a json representation of the layer weights. More...
 
template<typename T >
std::unique_ptr< BatchNorm2DLayer< T > > createBatchNorm2D (int num_filters_in, int num_features_in, const nlohmann::json &weights, T epsilon)
 
template<typename T , typename BatchNormType >
bool checkBatchNorm (const BatchNormType &batch_norm, const std::string &type, int layerDims, const nlohmann::json &weights, const bool debug)
 Checks that a BatchNorm1DLayer (or BatchNorm1DT) has the given dimensions. More...
 
template<typename T , typename BatchNormType >
bool checkBatchNorm2D (const BatchNormType &batch_norm, const std::string &type, int layerDims, const nlohmann::json &weights, const bool debug)
 Checks that a BatchNorm2DLayer (or BatchNorm2DT) has the given dimensions. More...
 
template<typename T >
std::unique_ptr< Activation< T > > createActivation (const std::string &activationType, int dims)
 Creates an activation layer of a given type. More...
 
template<typename LayerType >
bool checkActivation (const LayerType &actLayer, const std::string &activationType, int dims, const bool debug)
 Checks that an Activation layer has the given dimensions. More...
 
template<typename T >
std::unique_ptr< Model< T > > parseJson (const nlohmann::json &parent, const bool debug=false)
 Creates a neural network model from a json stream. More...
 
template<typename T >
std::unique_ptr< Model< T > > parseJson (std::ifstream &jsonStream, const bool debug=false)
 Creates a neural network model from a json stream. More...
 

Detailed Description

Utility functions for loading model weights from their json representation.

Function Documentation

◆ loadDense()

void RTNEURAL_NAMESPACE::json_parser::loadDense ( DenseType &  dense,
const nlohmann::json &  weights 
)

Loads weights for a Dense (or DenseT) layer from a json representation of the layer weights.

◆ createDense()

std::unique_ptr<Dense<T> > RTNEURAL_NAMESPACE::json_parser::createDense ( int  in_size,
int  out_size,
const nlohmann::json &  weights 
)

Creates a Dense layer from a json representation of the layer weights.

◆ checkDense()

bool RTNEURAL_NAMESPACE::json_parser::checkDense ( const DenseType &  dense,
const std::string &  type,
int  layerDims,
const bool  debug 
)

Checks that a Dense (or DenseT) layer has the given dimensions.

◆ loadConv1D()

void RTNEURAL_NAMESPACE::json_parser::loadConv1D ( Conv1DType &  conv,
int  kernel_size,
int  ,
const nlohmann::json &  weights 
)

Loads weights for a Conv1D (or Conv1DT) layer from a json representation of the layer weights.

◆ loadConv2D()

void RTNEURAL_NAMESPACE::json_parser::loadConv2D ( Conv2DType &  conv2d,
const nlohmann::json &  weights 
)

Loads weights for a Conv2D (or Conv2DT) layer from a json representation of the layer weights.

◆ createConv1D()

std::unique_ptr<Conv1D<T> > RTNEURAL_NAMESPACE::json_parser::createConv1D ( int  in_size,
int  out_size,
int  kernel_size,
int  dilation,
int  groups,
const nlohmann::json &  weights 
)

Creates a Conv1D layer from a json representation of the layer weights.

◆ checkConv1D()

bool RTNEURAL_NAMESPACE::json_parser::checkConv1D ( const Conv1DType &  conv,
const std::string &  type,
int  layerDims,
int  kernel_size,
int  dilation_rate,
int  groups,
const bool  debug 
)

Checks that a Conv1D (or Conv1DT) layer has the given dimensions.

◆ createConv2D()

std::unique_ptr<Conv2D<T> > RTNEURAL_NAMESPACE::json_parser::createConv2D ( int  num_filters_in,
int  num_features_in,
int  num_filters_out,
int  kernel_size_time,
int  kernel_size_feature,
int  dilation,
int  stride,
bool  valid_pad,
const nlohmann::json &  weights 
)

◆ checkConv2D()

bool RTNEURAL_NAMESPACE::json_parser::checkConv2D ( const Conv2DType &  conv,
const std::string &  type,
int  layerDims,
int  kernel_size_time,
int  kernel_size_feature,
int  dilation_rate,
int  stride,
bool  ,
const bool  debug 
)

Checks that a Conv2D (or Conv2DT) layer has the given dimensions.

◆ loadGRU()

void RTNEURAL_NAMESPACE::json_parser::loadGRU ( GRUType &  gru,
const nlohmann::json &  weights 
)

Loads weights for a GRULayer (or GRULayerT) from a json representation of the layer weights.

◆ createGRU()

std::unique_ptr<GRULayer<T> > RTNEURAL_NAMESPACE::json_parser::createGRU ( int  in_size,
int  out_size,
const nlohmann::json &  weights 
)

Creates a GRULayer from a json representation of the layer weights.

◆ checkGRU()

bool RTNEURAL_NAMESPACE::json_parser::checkGRU ( const GRUType &  gru,
const std::string &  type,
int  layerDims,
const bool  debug 
)

Checks that a GRULayer (or GRULayerT) has the given dimensions.

◆ loadLSTM()

void RTNEURAL_NAMESPACE::json_parser::loadLSTM ( LSTMType &  lstm,
const nlohmann::json &  weights 
)

Loads weights for a LSTMLayer (or LSTMLayerT) from a json representation of the layer weights.

◆ createLSTM()

std::unique_ptr<LSTMLayer<T> > RTNEURAL_NAMESPACE::json_parser::createLSTM ( int  in_size,
int  out_size,
const nlohmann::json &  weights 
)

Creates a LSTMLayer from a json representation of the layer weights.

◆ checkLSTM()

bool RTNEURAL_NAMESPACE::json_parser::checkLSTM ( const LSTMType &  lstm,
const std::string &  type,
int  layerDims,
const bool  debug 
)

Checks that a LSTMLayer (or LSTMLayerT) has the given dimensions.

◆ loadPReLU()

void RTNEURAL_NAMESPACE::json_parser::loadPReLU ( PReLUType &  prelu,
const nlohmann::json &  weights 
)

Loads weights for a PReLUActivation (or PReLUActivationT) from a json representation of the layer weights.

◆ createPReLU()

std::unique_ptr<PReLUActivation<T> > RTNEURAL_NAMESPACE::json_parser::createPReLU ( int  in_size,
const nlohmann::json &  weights 
)

Creates a PReLUActivation from a json representation of the layer weights.

◆ checkPReLU()

bool RTNEURAL_NAMESPACE::json_parser::checkPReLU ( const PReLUType &  prelu,
const std::string &  type,
int  layerDims,
const bool  debug 
)

Checks that a PReLUActivation (or PReLUActivationT) has the given dimensions.

◆ loadBatchNorm() [1/2]

void RTNEURAL_NAMESPACE::json_parser::loadBatchNorm ( BatchNormType &  batch_norm,
const nlohmann::json &  weights,
bool  affine 
)

Loads weights for a BatchNorm1DLayer (or BatchNorm1DT) or BatchNorm2DLayer (or BatchNorm2DT) from a json representation of the layer weights.

◆ loadBatchNorm() [2/2]

void RTNEURAL_NAMESPACE::json_parser::loadBatchNorm ( BatchNormType &  batch_norm,
const nlohmann::json &  weights 
)

Loads weights for a BatchNorm1DLayer (or BatchNorm1DT) from a json representation of the layer weights.

◆ createBatchNorm()

std::unique_ptr<BatchNorm1DLayer<T> > RTNEURAL_NAMESPACE::json_parser::createBatchNorm ( int  size,
const nlohmann::json &  weights,
epsilon 
)

Creates a BatchNorm1DLayer from a json representation of the layer weights.

◆ createBatchNorm2D()

std::unique_ptr<BatchNorm2DLayer<T> > RTNEURAL_NAMESPACE::json_parser::createBatchNorm2D ( int  num_filters_in,
int  num_features_in,
const nlohmann::json &  weights,
epsilon 
)

◆ checkBatchNorm()

bool RTNEURAL_NAMESPACE::json_parser::checkBatchNorm ( const BatchNormType &  batch_norm,
const std::string &  type,
int  layerDims,
const nlohmann::json &  weights,
const bool  debug 
)

Checks that a BatchNorm1DLayer (or BatchNorm1DT) has the given dimensions.

◆ checkBatchNorm2D()

bool RTNEURAL_NAMESPACE::json_parser::checkBatchNorm2D ( const BatchNormType &  batch_norm,
const std::string &  type,
int  layerDims,
const nlohmann::json &  weights,
const bool  debug 
)

Checks that a BatchNorm2DLayer (or BatchNorm2DT) has the given dimensions.

◆ createActivation()

std::unique_ptr<Activation<T> > RTNEURAL_NAMESPACE::json_parser::createActivation ( const std::string &  activationType,
int  dims 
)

Creates an activation layer of a given type.

◆ checkActivation()

bool RTNEURAL_NAMESPACE::json_parser::checkActivation ( const LayerType &  actLayer,
const std::string &  activationType,
int  dims,
const bool  debug 
)

Checks that an Activation layer has the given dimensions.

◆ parseJson() [1/2]

std::unique_ptr<Model<T> > RTNEURAL_NAMESPACE::json_parser::parseJson ( const nlohmann::json &  parent,
const bool  debug = false 
)

Creates a neural network model from a json stream.

◆ parseJson() [2/2]

std::unique_ptr<Model<T> > RTNEURAL_NAMESPACE::json_parser::parseJson ( std::ifstream &  jsonStream,
const bool  debug = false 
)

Creates a neural network model from a json stream.