fynance.models.recurrent_neural_network.LongShortTermMemory

class fynance.models.recurrent_neural_network.LongShortTermMemory(X, y, drop=None, x_type=None, y_type=None, bias=True, forward_activation=<class 'torch.nn.modules.activation.Softmax'>, hidden_activation=<class 'torch.nn.modules.activation.Tanh'>, hidden_state_size=None, memory_activation=<class 'torch.nn.modules.activation.Tanh'>, memory_state_size=None, forget_activation=<class 'torch.nn.modules.activation.Sigmoid'>, update_activation=<class 'torch.nn.modules.activation.Sigmoid'>, output_activation=<class 'torch.nn.modules.activation.Sigmoid'>)

Long short term memory neural network.

Parameters:
X, y : array-like or int
  • If it’s an array-like, respectively inputs and outputs data.
  • If it’s an integer, respectively dimension of inputs and outputs.
drop : float, optional

Probability of an element to be zeroed.

forward_activation : torch.nn.Module, optional

Activation functions, default is Softmax.

hidden_activation, memory_activation : torch.nn.Module, optional

Activation functions for respectively hidden and memory state, default both are Tanh function.

hidden_state_size, memory_state_size : int, optional

Size of respectively hidden and memory states, default hidden state is the same size than input and default memory state is the same size than hidden state.

forget_activation, updated_activation, output_activation : torch.nn.Module,
optional

Activation functions for respectively forget, update and output gate, default are Sigmoid function for the three.

Attributes:
criterion : torch.nn.modules.loss

A loss function.

optimizer : torch.optim

An optimizer algorithm.

W_f, W_i, W_o, W_c, W_y : torch.nn.Linear

Respectively forget, update and output gate weights, weight to compute the candidate value for cell memory and forward weight.

f_f, f_i, f_o, f_c, f_y : torch.nn.Module

Respectively activation function for forget, update and output gate, activation function to compute the candidate value for cell memory and forward activation function.

Methods

__call__(*input, **kwargs)
set_optimizer(criterion, optimizer[, params]) Set the optimizer object.
train_on(X, y, H, C) Trains the neural network model.
predict(X, H, C) Predicts outputs of neural network model.
set_data(X, y[, x_type, y_type]) Set data inputs and outputs.