NeuralNetwork how to give in input and output

hello,
I know to most of you this question might be silly and stupid but I cannot find the correct answer anywhere. I am stuck in the model training process with CNNs where I cannont find out the following: How to give the trainnetwork function the input as well as the output. My input in that case is a 1D cell array (6570x1) and my output is a 3D(10x10x5) cell array. I am familiar with how to do that in python, where the fit-function takes in both, the input as well as the output argument. Is there a similar way to do this in Matlab? Since I don´t see any solution to this. thank you so much in advance.

1 comentario

Kuno Bruswachtl
Kuno Bruswachtl el 29 de Dic. de 2021
or must I create the input and the output in a featuremap, where each cell corresponds to another cell?

Iniciar sesión para comentar.

 Respuesta aceptada

As per my knowledge, the first approach is to use imageInputLayer as input layer of your network (I think with featureInputLayer as input layer it may not work) and prepare the training data according to the format mentioned in the images & responses sections of the trainNetwork function.
The following is a very basic example:
layers = [imageInputLayer([600 1 1])
resize3dLayer(OutputSize=[10 20 3])
regressionLayer];
analyzeNetwork(layers)
batchSize = 5;
xtrain = randn(600,1,1,batchSize);
ytrain = randn(10,20,3,batchSize);
options = trainingOptions("sgdm");
net = trainNetwork(xtrain,ytrain,layers,options)
The other way is to not use trainNetwork function and instead use dlnetwork & Deep Learning Custom Training Loops based workflow.

5 comentarios

hello,
first of all thank you for this helpful answer it makes a lot more sense now.
However I am still not able to use the cells itself as an input but have to convert them first into an array to be able to use them in trainnetwork. I have a 1x7000 cell, where each of these 7000 cells as contains a 6570x1 double, which is used as my input. If I convert this to an array it is possible use, but I would rather go with cells. Any ideas?
thank you
You can check the following sections of trainNetwork function for more information:
For input data & input layer:
  1. images for imageInputLayer & image3dInputLayer
  2. features for featureInputLayer
  3. sequences for sequenceInputLayer
For response/target data: responses.
Note that the input does not necessarily has to be an image for imageInputLayer and same is the case for other input layers as well.
Hi again,
I did read the documantation multiple times. Yet I cannot find a solution to how specifically use cells as an input data. also all the given examples never ellaborate on that specific topic. I am sorry but I am reallly lost her :/
As per my knowledge, in summary only if your input layer is sequencInputLayer then you can use cell arrays, for all other input layers the training data should either be a datastore, a table or numeric arrays.
alright, i guess I got it. Thank you for your help!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Deep Learning Toolbox en Centro de ayuda y File Exchange.

Productos

Versión

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by