How to apply a 2D matrix input to a trainNetwork?
4 vues (au cours des 30 derniers jours)
I have the following piece of code for training a network:
layers = [
maxEpochs = 100;
options = trainingOptions('adam', ...
net = trainNetwork(xt,yt,layers,options);
screenshot of a sample xt and yt is given below:
Basically each yt corresponds to a 3 by 5 matrix in xt. where 3 is the number of rows in the sequence and 5 is the number of features. Basically xt contains a sequence of stock prices - the 4 prices and volume, after scaling. yt corresponds to future close price.
I want to train the network with this. And I have tried various combinations, reshaping, converting it to cells etc. But its one error or the other.
Does someone know if its possible to do what I am trying to do? I am using version 2020b.
The current error is:
Error using trainNetwork (line 183)
The training sequences are of feature dimension 4 5 but the input layer expects sequences of feature dimension 5.
Joss Knight le 8 Sep 2023
Consult the documentation here.
Typically sequence data is passed in as a cell array. In each cell you would be passing one sequence. If you want to pass a single numeric array then I think all you need to do is permute dims 1 and 2 - you have to put the features down the columns, i.e. each column is an observation. Arrangement is C-by-B-by-T.