Input structure for BiLSTM
6 ビュー (過去 30 日間)
古いコメントを表示
I keep getting this error when i run my BiLSTM model "Error using trainNetwork (line 165)
Invalid training data. Predictors must be a N-by-1 cell array of sequences, where N is the number of
sequences. All sequences must have the same feature dimension and at least one time step."
My X_train data is a 134949x1 cell with Nx1 nested cells that hold cells with 70x1 double
and my Y_train data is a 134949x1 cell with Nx1 nested cells that hold cells with 65x1 double.
I do not know what is wrong as the error says it should be N-by-1 cell array and I believe that is how my data is stored.
2 件のコメント
Pravin Jagtap
2019 年 8 月 22 日
Hello Sanjana,
I would like to know the way you maintained the structure of data has any significance? I need some more information on the description of data than only sizes of cell arrays so that we can think of reshaping/unwrapping the data in the required form.
Kind Regards
~Pravin
回答 (1 件)
Pravin Jagtap
2019 年 8 月 23 日
編集済み: Pravin Jagtap
2019 年 8 月 23 日
Hello Sanjana,
Refer to following example in order to understand the desired structures of cell arrays of training data for Bi-LSTM model by going through the example:
In your case, there are 3 nested cell arrays whereas example mentioned above uses 2 nested cell arrays. Important thing to note here is we can have 2-D cell structure inside the main cell array. In your case you can combine N X 1 and 70 X 1 into one cell array 2-D cell array) which will be consistent with the desired structure of cell array as per above example.
To achieve the unwrapping/reshaping you can use the horizontal or vertical concatenation using following code:
%% Generating the Data
>>data={{1;2;3};{4;5;6};{7;8;9}};
%% Vertical concatenation
>>cell2mat(vertcat(data{:}));
%% Horizontal concatenation
>>cell2mat(horzcat(data{:}));
In general, for Bi-LSTM, make sure ‘X_Train‘ should have cell array size of ‘n X 1’ and each cell represents ‘f X l’ cell array size where f is number of features and l is length of each cell array data
( Note: f should be fixed whereas l can vary and follow the example given above to understand the desired structure of cell array for Bi-LSTM model.)
Kind Regards
~Pravin
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Sequence and Numeric Feature Data Workflows についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!