snrv.Snrv¶
- class snrv.Snrv(input_size, output_size, hidden_depth=2, hidden_size=100, activation=ReLU(), batch_norm=False, dropout_rate=0.0, lr=0.1, weight_decay=0.0, val_frac=0.2, n_epochs=100, batch_size=100, VAMPdegree=2, is_reversible=True)[source]¶
ANN encoder for state-free reversible VAMPnet
- Parameters
input_size (int) – number of neurons in input layer
output_size (int) – number of neurons in output layer corresponding to number of basis functions to compute for VAC / VAMP
hidden_depth (int, default = 2) – number of hidden layers
hidden_size (int, default = 100) – number of neurons in each hidden layer
activation (str, default = nn.ReLU()) – activation function to be used in each neuron
batch_norm (bool, default = False) – use batch normalization after each layer
dropout_rate (float, default = 0.) – dropout rate to use in each layer
lr (float, default = 0.1) – learning rate for Adam optimizer
weight_decay (float, default = 0.) – weight decay for Adam optimizer
val_frac (float, default = 0.2) – fraction of data to place in validation partition; balance is used for training
n_epochs (int, default = 100) – number of training epochs for ANN
batch_size (int, default = 100) – no. of instances per mini batch
VAMPdegree (int, default = 2) – exponent to use in VAMP-r score loss function
is_reversible (bool, default = True) – indicator flag as to whether to enforce detailed balance by symmetrizing trajectory by augmenting with time reversed twin and solve VAC OR not assume microscopic reversibility and solve VAMP
- Variables
self.device (str) – specification as to whether to use ‘cpu’ or ‘cuda’ for model training
self.is_fitted (bool) – indicator flag as to whether or nor model has been fitted
self._train_loader (DataLoader object) – training data loader
self._val_loader (DataLoader object) – validation data loader
self.lag (int) – lag in steps to apply to data trajectory
self.optimizer (torch.optim.Adam object) – optimizer for backpropagation
self._train_step (function) – training step function produced by self._make_train_step
self.evals (torch.tensor, n_comp, n_comp = no. of basis functions in ANN == output_size) – eigenvalues of VAC generalized eigenvalue problem finding linear combination of learned basis functions to produce approximations of transfer operator eigenvectors in non-ascending order OR singular values of VAMP singular value problem finding linear combination of learned basis functions to produce approximations of transfer operator left and right singular vectors in non-ascending order
self.expansion_coefficients (n_comp, n_comp = no. of basis functions in ANN == output_size) – expansion coefficients for linear combination of learned basis functions into transfer operator eigenvectors (reversible) or left singular vectors (non-reversible)
self.expansion_coefficients_right (n_comp, n_comp = no. of basis functions in ANN == output_size) – expansion coefficients for linear combination of learned basis functions into transfer operator right singular vectors (non-reversible)
self.training_losses (list, n_epoch) – loss over training data in each epoch
self.validation_losses (list, n_epoch) – loss over validation data in each epoch
- __init__(input_size, output_size, hidden_depth=2, hidden_size=100, activation=ReLU(), batch_norm=False, dropout_rate=0.0, lr=0.1, weight_decay=0.0, val_frac=0.2, n_epochs=100, batch_size=100, VAMPdegree=2, is_reversible=True)[source]¶
Initializes internal Module state, shared by both nn.Module and ScriptModule.
Methods
__init__(input_size, output_size[, ...])Initializes internal Module state, shared by both nn.Module and ScriptModule.
add_module(name, module)Adds a child module to the current module.
apply(fn)Applies
fnrecursively to every submodule (as returned by.children()) as well as self.bfloat16()Casts all floating point parameters and buffers to
bfloat16datatype.buffers([recurse])Returns an iterator over module buffers.
children()Returns an iterator over immediate children modules.
cpu()Moves all model parameters and buffers to the CPU.
cuda([device])Moves all model parameters and buffers to the GPU.
double()Casts all floating point parameters and buffers to
doubledatatype.eval()Sets the module in evaluation mode.
extra_repr()Set the extra representation of the module
fit(data, lag[, ln_pathweight])fit SNRV model to data
fit_transform(data, lag[, ln_pathweight])fit SNRV over data then project data into learned eigenvector (VAC) / singular vectors (VAMP) of transfer operator
float()Casts all floating point parameters and buffers to float datatype.
forward(x_t0, x_tt)Forward pass through network
get_transform_Jacobian(data)compute Jacobian of self.transform computational graph output (psi) wrt input (data)
half()Casts all floating point parameters and buffers to
halfdatatype.load_state_dict(state_dict[, strict])Copies parameters and buffers from
state_dictinto this module and its descendants.load_weights(network_weights)loading SNRV network weights from file
modules()Returns an iterator over all modules in the network.
named_buffers([prefix, recurse])Returns an iterator over module buffers, yielding both the name of the buffer as well as the buffer itself.
named_children()Returns an iterator over immediate children modules, yielding both the name of the module as well as the module itself.
named_modules([memo, prefix])Returns an iterator over all modules in the network, yielding both the name of the module as well as the module itself.
named_parameters([prefix, recurse])Returns an iterator over module parameters, yielding both the name of the parameter as well as the parameter itself.
parameters([recurse])Returns an iterator over module parameters.
register_backward_hook(hook)Registers a backward hook on the module.
register_buffer(name, tensor[, persistent])Adds a buffer to the module.
register_forward_hook(hook)Registers a forward hook on the module.
register_forward_pre_hook(hook)Registers a forward pre-hook on the module.
register_full_backward_hook(hook)Registers a backward hook on the module.
register_parameter(name, param)Adds a parameter to the module.
requires_grad_([requires_grad])Change if autograd should record operations on parameters in this module.
save_model(modelFilePath)saving model parameters required for building and running (i.e., self.transform)
share_memory()state_dict([destination, prefix, keep_vars])Returns a dictionary containing a whole state of the module.
to(*args, **kwargs)Moves and/or casts the parameters and buffers.
train([mode])Sets the module in training mode.
transform(data)project data into learned eigenvector basis
type(dst_type)Casts all parameters and buffers to
dst_type.xpu([device])Moves all model parameters and buffers to the XPU.
zero_grad([set_to_none])Sets gradients of all model parameters to zero.
Attributes
T_destinationalias of TypeVar('T_destination', bound=
Mapping[str,torch.Tensor])dump_patchesThis allows better BC support for
load_state_dict().