Hopfield
Hopfield class : it inherits from Base class and implements the unsupervised neural network based on the Hopfield model. Notice that it has some specific parameters to set the strength of the anti-hebbian learning and to customize some of the model hyper-parameters.
- class biolearn.model.hopfield.Hopfield(inputs=None, outputs=100, num_epochs=100, batch_size=100, weights_init=Normal(mu=0.0, std=1.0), optimizer=SGD(lr_max=inf, lr_min=0.0, decay=0.0, lr=0.02), delta=0.4, p=2.0, k=2, precision=1e-30, epochs_for_convergency=None, convergency_atol=0.01, random_state=None, verbose=True)[source]
Bases:
Base- Parameters
inputs (int (default=None)) – Number of input units
outputs (int (default=100)) – Number of hidden units
num_epochs (int (default=100)) – Maximum number of epochs for model convergency
batch_size (int (default=10)) – Size of the minibatch
weights_init (BaseWeights (default=Normal)) – Weights initialization strategy object
optimizer (Optimizer (default=SGD)) – Optimizer object
delta (float (default=0.4)) – Strength of the anti-hebbian learning
p (float (default=2.)) – Lebesgue norm of the weights
k (int (default=2)) – Ranking parameter, must be an integer greater or equal to 1
precision (float (default=1e-30)) – Parameter that controls numerical precision of the weight updates
epochs_for_convergency (int (default=None)) – Number of stable epochs requested for the convergency. If None the training proceeds up to the maximum number of epochs (num_epochs)
convergency_atol (float (default=0.01)) – Absolute tolerance requested for the convergency
random_state (int (default=None)) – Random seed for weights generation
verbose (bool (default=True)) – Turn on/off the verbosity
- fit(X, y=None)
Fit the biolearn model weights.
- Parameters
X (array-like of shape (n_samples, n_features)) – The training input samples
y (array-like, default=None) – The array of labels
- Returns
self – Return self
- Return type
object
- fit_transform(X, y=None)
Fit the model model meta-transformer and apply the data encoding transformation.
- Parameters
X (array-like of shape (n_samples, n_features)) – The training input samples
y (array-like, shape (n_samples,)) – The target values
- Returns
Xnew – The data encoded according to the model weights.
- Return type
array-like of shape (n_samples, encoded_features)
- get_params(deep=True)
Get parameters for this estimator.
- Parameters
deep (bool, default=True) – If True, will return the parameters for this estimator and contained subobjects that are estimators.
- Returns
params – Parameter names mapped to their values.
- Return type
dict
- load_weights(filename)
Load the weight matrix from a binary file.
- Parameters
filename (str) – Filename or path
- Returns
self – Return self
- Return type
object
- predict(X, y=None)
Reduce X applying the biolearn encoding.
- Parameters
X (array of shape (n_samples, n_features)) – The input samples
y (array-like, default=None) – The array of labels
- Returns
Xnew – The encoded features
- Return type
array of shape (n_values, n_samples)
- save_weights(filename)
Save the current weights to a binary file.
- Parameters
filename (str) – Filename or path
- Return type
True if everything is ok
- set_params(**params)
Set the parameters of this estimator.
The method works on simple estimators as well as on nested objects (such as
Pipeline). The latter have parameters of the form<component>__<parameter>so that it’s possible to update each component of a nested object.- Parameters
**params (dict) – Estimator parameters.
- Returns
self – Estimator instance.
- Return type
estimator instance
- transform(X)
Apply the data reduction according to the features in the best signature found.
- Parameters
X (array-like of shape (n_samples, n_features)) – The input samples
- Returns
Xnew – The data encoded according to the model weights.
- Return type
array-like of shape (n_samples, encoded_features)