nn.py¶

Methods for working with neural networks and other model classes for use with backpropogation and training.
If you find these codes or methods helpful for your project, please cite our related work.
- class nn.AtzLearnableTensorFunc(*args, **kwargs)¶
Function for a learnable tensor (deprecated). This was put in place to address issue with an early version of pytorch. This may be removed in future versions.
- __module__ = 'nn'¶
- static backward(ctx, grad_output)¶
Computes the gradient.
- static forward(ctx, X, tensor, params=None)¶
Function evaluation that returns a tensor.
- Paramaters:
X (Tensor): input values tensor (Tensor): tensor to return independent of X.
- Returns:
output (Tensor) – a constant tensor with shape [num_samples,*tensor.shape].
- class nn.AtzLearnableTensorLayer(**params)¶
Module for storing a learnable tensor (deprecated). This was put in place to address issue with an early version of pytorch. This may be removed in future versions.
- __init__(**params)¶
Initialized the class.
- __module__ = 'nn'¶
- extra_repr()¶
Give a string representation of the parameters.
- forward(X)¶
Evaluate the tensor.
- to(device)¶
Maps data to a specified device.
- training: bool¶
- class nn.MLP1(layer_sizes=None, layer_act_types=None, flag_bias=True, activation_func=None, device=None, flag_verbose=0)¶
Creates a Multilayer Perceptron (MLP) with the specified architecture.
- ACT_TYPE_None = 'None'¶
- ACT_TYPE_RBF = 'RBF'¶
- ACT_TYPE_ReLU = 'ReLU'¶
- ACT_TYPE_Sigmoid = 'Sigmoid'¶
- __init__(layer_sizes=None, layer_act_types=None, flag_bias=True, activation_func=None, device=None, flag_verbose=0)¶
Initializes Multilayer Perceptron (MLP) to have a specified architecture.
- Parameters:
layer_size (list) – size of each processing layer
layer_act_types (list) – activation function types to use after each layer
flag_bias (boolean) – if biases should be used for layers
activation_func (function) – default activation function to use
device (torch.device) – specified device on which to setup the model
flag_verbose (int) – level of messages to report during calculations
- __module__ = 'nn'¶
- static create_from_pickle(filename)¶
Re-create the neural network from saved data.
- static create_from_save_data(s)¶
Re-create the neural network from saved data.
- forward(input, params=None)¶
Applies the Multilayer Perceptron (MLP) to the input data.
- Parameters:
input (Tensor) – the input for the MLP to process
params (dict) – parameters for the network (see examples and codes).
- Returns:
output (Tensor) – the evaluation of the network. Returns tensor of size [batch,1].
- load_from_pickle(filename)¶
Load the weights from pickle file. Assumes current architecture same as the saved data.
- save_to_pickle(filename)¶
Save the weights to a pickle file.
- to(device, **extra_params)¶
Moves data to the specified device, gpu, cpu, or other.
- training: bool¶