Is it possible to use sequence input in CNN without using cell arrays?

3 visualizzazioni (ultimi 30 giorni)
I try to train CNN with 1D vector input data. The use of the feature input layer does not give high efficiency. Sequnce input layer requires data conversion to cell arrays, with the amount of data I have, it is impossible. Is there a workaround for this problem? I have matlab2021b. I tried to use 1D vector as image input layer [9 1 1]. Thanks to this, I get the appropriate effectiveness, but it is difficult to justify it in a scientific article.

Risposte (1)

Shubham
Shubham il 28 Lug 2023
Hi Kamila,
If you are working with 1D vector input data and want to train a CNN in MATLAB without using the sequence input layer, you can consider reshaping your data into a 2D matrix and using the image input layer. This approach allows you to leverage the existing functionality of CNNs in MATLAB while still working with your 1D data.
Here's an example of how you can reshape your 1D vector data into a 2D matrix and use it with the image input layer:
% Assuming your 1D vector data is stored in 'inputData'
inputData = [1, 2, 3, 4, 5, 6, 7, 8, 9];
% Reshape the 1D vector into a 2D matrix
reshapedData = reshape(inputData, [1, numel(inputData)]);
% Create the array datastore
ds = arrayDatastore(reshapedData);
% Create the image input layer with appropriate input size
imageInputSize = size(reshapedData);
imageInputLayer = imageInputLayer(imageInputSize);
% Create the rest of your CNN layers
...
% Train your CNN model
...
I hope, this will work.

Categorie

Scopri di più su Image Data Workflows in Help Center e File Exchange

Prodotti


Release

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by