FilippoMB / Time-series-classification-and-clustering-with-Reservoir-Computing

Library for implementing reservoir computing models (echo state networks) for multivariate time series classification and clustering.
https://reservoir-computing.readthedocs.io/en/latest/
MIT License
351 stars 85 forks source link

ESN predicting constant values in classification #5

Closed Laoban-man closed 3 years ago

Laoban-man commented 3 years ago

Hi, I'm using the ESNClassification to classify a binary outcome from data which is input in the format (N,T,V). I've played around with the hyperparameters but no matter the combination, I get either only ones or only zeroes.

Here is the config set-up:

`config['seed'] = 1 np.random.seed(config['seed'])

Hyperarameters of the reservoir

config['n_internal_units'] = 100 # size of the reservoir config['spectral_radius'] = 0.4 # largest eigenvalue of the reservoir config['leak'] = 0.5 # amount of leakage in the reservoir state update (None or 1.0 --> no leakage) config['connectivity'] = 0.1 # percentage of nonzero connections in the reservoir config['input_scaling'] = 0.1 # scaling of the input weights config['noise_level'] = 0.01 # noise in the reservoir state update config['n_drop'] = 0 # transient states to be dropped config['bidir'] = False # if True, use bidirectional reservoir config['circ'] = False # use reservoir with circle topology

Dimensionality reduction hyperparameters

config['dimred_method'] ='tenpca' # options: {None (no dimensionality reduction), 'pca', 'tenpca'} config['n_dim'] = 40 # number of resulting dimensions after the dimensionality reduction procedure

Type of MTS representation

config['mts_rep'] = 'last' # MTS representation: {'last', 'mean', 'output', 'reservoir'} config['w_ridge_embedding'] = 5.0 # regularization parameter of the ridge regression

Type of readout

config['readout_type'] = 'mlp' # readout used for classification: {'lin', 'mlp', 'svm'}

Linear readout hyperparameters

config['w_ridge'] = 5.0 # regularization of the ridge regression readout

SVM readout hyperparameters

config['svm_gamma'] = 0.005 # bandwith of the RBF kernel config['svm_C'] = 5.0 # regularization for SVM hyperplane

MLP readout hyperparameters

config['mlp_layout'] = (40,1) # neurons in each MLP layer config['num_epochs'] = 20 # number of epochs config['w_l2'] = 0.05 # weight of the L2 regularization config['nonlinearity'] = 'relu' # type of activation function {'relu', 'tanh', 'logistic', 'identity'}`

And the format of the input for training: print(X_tr.shape) print(X_te.shape) print(y_tr.shape) print(y_te.shape) with output: (7801, 200, 130) (1132, 200, 130) (7801, 1) (1132, 1)

when I train on X_tr and y_tr, the output are either all ones or all zeroes. Any guidance on what could be causing this error? Cheers

FilippoMB commented 3 years ago

Hi,

cannot say for sure without looking at the data. Are you passing the labels one-hot encoded vectors? In particular, y_tr and y_te should have the second dimension equal to 2, if you have a two-class problem.

Also, try with a linear readout first: config['readout_type'] = 'lin'