BILSTM input data length

3 visualizzazioni (ultimi 30 giorni)
Walid
Walid il 4 Set 2025
Commentato: Umar il 6 Set 2025
Can I input a short length features vector as input data to BILSTM network (contrary to sequence data) ? this vector can include a parameters values of health indicators

Risposte (1)

Umar
Umar il 5 Set 2025
Modificato: Umar il 5 Set 2025

Hi @Walid,

Yes, you can input short feature vectors to BiLSTM networks, though this requires proper data formatting. BiLSTM layers expect sequence data with dimensions [batchSize, sequenceLength, numFeatures].

For health indicator parameters, reshape your feature vector accordingly:

% Example: 10 health parameters as features
healthFeatures = [glucose, bp, cholesterol, ...]; % 1×10 vector
% Reshape for BiLSTM: treat as single timestep
inputData = reshape(healthFeatures, 1, 1, 10); % [1, 1, 10]

However, consider whether BiLSTM is optimal for non-sequential health indicators. Standard feedforward networks or classification layers may be more appropriate for static feature vectors, as BiLSTM's temporal modeling capabilities are underutilized without sequential dependencies.

References

BiLSTM Layer Documentation: https://www.mathworks.com/help/deeplearning/ref/bilstmlayer.html

Sequence Input Layer: https://www.mathworks.com/help/deeplearning/ref/sequenceinputlayer.html

Classification with LSTM Networks: https://www.mathworks.com/help/deeplearning/ug/classify-sequence-data-using-lstm-networks.html

If your health indicators have temporal relationships or you plan to extend to time-series analysis, BiLSTM remains suitable.

  2 Commenti
Chuguang Pan
Chuguang Pan il 5 Set 2025
The desired data format of bilstmLayer should be "CBT"=[Channel, Batchsize, SequenceLength], not "BTC". The "BTC" is PyTorch Tensor data format.
Umar
Umar il 6 Set 2025

Hi @Walid,

Thanks to @Chuguang Pan for highlighting the MATLAB BiLSTM input format. MATLAB expects CBT (Channel, Batch, Time), unlike PyTorch which uses BTC. This distinction is crucial to avoid subtle bugs when porting ideas between frameworks.

MathWorks: Deep Learning Data Formats https://www.mathworks.com/help/deeplearning/ug/deep-learning-data-formats.html

% Example: 10 health indicators in a 1×10 row vector
healthFeatures = [100, 120, 180, 5.5, 72, 95, 80, 1.2, 0.8, 6.4];
% Reshape to CBT: C=10 features, B=1 sample, T=1 timestep
X = reshape(healthFeatures(:), [numel(healthFeatures), 1, 1]);
% Inspect the size and values
size(X)        % -> 10 1 1
disp(X(:,:,1)) % displays the 10 features

Please see attached.

Optional: Deep Learning Toolbox, if you have access to it.

Xdl = dlarray(X, "CBT");  % Channel, Batch, Time

Practical Notes

1. Static indicators: For single-timestep, non-sequential features, a feed-forward network or classification layers often suffice. BiLSTM is most effective for sequences with T > 1

 ([MathWorks: Classify Sequence Data Using LSTM Networks]
( <https://www.mathworks.com/help/deeplearning/ug/classify-sequence-data-using-lstm-networks.html> )

2. Multiple samples: To batch multiple single-timestep samples, concatenate along the B dimension:

X = cat(2, X1, X2, ...);  % C × B × T

3. This ensures MATLAB BiLSTM layers receive correctly formatted data and avoids subtle dimensional errors.

Accedi per commentare.

Categorie

Scopri di più su AI for Signals and Images in Help Center e File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by