Borrar filtros
Borrar filtros

1D-CNN not sequence input

19 visualizaciones (últimos 30 días)
ababa
ababa el 5 de Abr. de 2024
Editada: Fabien SANCHEZ el 30 de Mayo de 2024
I am trying to learn a 1D-CNN model. I only have sequence input examples, but I want to learn CNN with no sequence input. My data is a one-dimensional vector. When I input a one-dimensional vector as 100x1 as a cell, I failed to train the network because matlab outputs errors. However, I have succeeded in training when I input a one-dimensional vector as 1x100 as a cell. To input it as 1x100, I need to set numFeature as 1. I want to set numFeature to 100. How can I do this with a vector not a sequence of 2d matrix?
related exampled is below:
  1 comentario
ababa
ababa el 5 de Abr. de 2024
The sequence length of the input data (1) must be greater than or equal to the MinLength property of the sequence input layer (100).

Iniciar sesión para comentar.

Respuesta aceptada

Ben
Ben el 8 de Abr. de 2024
The convolution1dLayer only supports convolutions over "sequence dimension" or a single "spatial dimension".
If you want to perform 1D convolution over your feature dimension, you can try the following.
Interpret your feature dimension as a spatial or sequence dimension. For example instead of interpreting N observations of 100 features as a 100xN "CB" array, you can interpret it as a 100x1xN "SCB" array. To use this data in dlnetwork you can use the R2023b feature inputLayer. For example
numFeatures = 100;
batchSize = 4;
% create fake data as "CB"
x = dlarray(rand(numFeatures,batchSize),"CB");
% re-label data as "SBC" so 1d conv can be used on the C dimension
x = dlarray(x,"SBC");
% create 1d conv network
filterSize = 3;
numFilters = 8;
layers = [
inputLayer([numFeatures,1,NaN], "SCB")
convolution1dLayer(filterSize,numFilters)];
net = dlnetwork(layers);
% test network
y = predict(net,x);
% If later the "SCB" outputs have a scalar "C" dimension and you want to relabel to "CB" you can use something like:
relabelLayer = functionLayer(@(x) dlarray(squeeze(x),"CB"));
  1 comentario
Fabien SANCHEZ
Fabien SANCHEZ el 30 de Mayo de 2024
Editada: Fabien SANCHEZ el 30 de Mayo de 2024
Hi there!
This works with the Matlab interface. If the agent is trained by reinforcement in a Simulink environment via a Simulink.bus that brings observations spaces, how do we force the input to be in "TCB" format? Do you see the lack of support for cell objects or dlarray in Simulink signals?
Every time I try, the output format of the layer is a A(C)x1(B)x1(T), where A is the number of timesteps in the sequence. And I can not use this format to train, due to a crash after the episode reached the 100 batches for obscure reshaping reasons. I would like to have a 1Cx1BxAT but I could not find a good way to force it.
I can provide simulink model/code if needed. It takes place in a context of multi-input model (features and sequences).

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Sequence and Numeric Feature Data Workflows en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by