The value of 'ValidationData' is invalid. Duplicate table variable name: 'input'. error during neural network training

8 visualizaciones (últimos 30 días)
I want to train an autoencoder that copies the input image.
I used augmentedImageDatastore for image resizing, then combined two augmentedImageDatastore to use as input and responses using the 'combine' function for the autoencoder.
However, If i run the code below, I see the error message:
The value of 'ValidationData' is invalid. Duplicate table variable name: 'input'.
I checked the 'combine' function for 'ImageDatastore' work well but I am not sure why it is not work for 'augmentedImageDatastore'.
Thank you for your help.
digitDatasetPath = fullfile("my path");
imds = imageDatastore(digitDatasetPath, ...
IncludeSubfolders=true,LabelSource="foldernames");
imds.ReadSize = 1024;
imds = shuffle(imds);
[imdsTrain,imdsVal,imdsTest] = splitEachLabel(imds,0.95,0.025);
% Create augmented datastores for input and response
augmentedTrainInput = augmentedImageDatastore([224,224,3], imdsTrain);
augmentedTrainOutput = augmentedImageDatastore([224,224,3], imdsTrain);
augmentedValInput = augmentedImageDatastore([224,224,3], imdsVal);
augmentedValOutput = augmentedImageDatastore([224,224,3], imdsVal);
augmentedTestInput = augmentedImageDatastore([224,224,3], imdsTest);
augmentedTestOutput = augmentedImageDatastore([224,224,3], imdsTest);
% Combine the augmented datastores for input and response
dsTrain = combine(augmentedTrainInput, augmentedTrainOutput);
dsVal = combine(augmentedValInput, augmentedValOutput);
dsTest = combine(augmentedTestInput, augmentedTestOutput);
% Define the network layers
imageLayer = imageInputLayer([224,224,3]);
encodingLayers = [ ...
convolution2dLayer(3,8,Padding="same"), ...
reluLayer, ...
maxPooling2dLayer(2,Padding="same",Stride=2), ...
convolution2dLayer(3,16,Padding="same"), ...
reluLayer, ...
maxPooling2dLayer(2,Padding="same",Stride=2), ...
convolution2dLayer(3,32,Padding="same"), ...
reluLayer, ...
maxPooling2dLayer(2,Padding="same",Stride=2)];
decodingLayers = [ ...
transposedConv2dLayer(2,32,Stride=2), ...
reluLayer, ...
transposedConv2dLayer(2,16,Stride=2), ...
reluLayer, ...
transposedConv2dLayer(2,8,Stride=2), ...
reluLayer, ...
convolution2dLayer(1,3,Padding="same"), ...
clippedReluLayer(1.0), ...
regressionLayer];
layers = [imageLayer,encodingLayers,decodingLayers];
options = trainingOptions("adam", ...
MaxEpochs=50, ...
MiniBatchSize=imds.ReadSize, ...
ValidationData=dsVal, ...
ValidationPatience=5, ...
Plots="training-progress", ...
OutputNetwork="best-validation-loss", ...
ExecutionEnvironment="multi-gpu", ...
DispatchInBackground=true,...
Verbose=true);
net = trainNetwork(dsTrain,layers,options);
modelDateTime = string(datetime("now",Format="yyyy-MM-dd-HH-mm-ss"));
save("trainedImageToImageRegressionNet-"+modelDateTime+".mat","net");
ypred = predict(net,dsTest);
testBatch = preview(dsTest);
idx = 1;
y = ypred(:,:,:,idx);
x = testBatch{idx,1};
ref = testBatch{idx,2};
montage({x,y});

Respuesta aceptada

Joss Knight
Joss Knight el 13 de Sept. de 2023
augmentedImageDatastore returns a table so cannot be trivially combined. You should first transform it to convert it into a cell array of just the input values.
>> amds = augmentedImageDatastore([224,224,3],digitDatastore);
>> read(amds)
ans =
128×2 table
input response
_______________ ________
{224×224 uint8} 0
{224×224 uint8} 0
{224×224 uint8} 0
{224×224 uint8} 0
{224×224 uint8} 0
{224×224 uint8} 0
{224×224 uint8} 0
{224×224 uint8} 0
: :
Display all 128 rows.
>> amds = transform(augmentedImageDatastore([224,224,3],digitDatastore), @(t)t.input);
>> read(amds)
ans =
128×1 cell array
{224×224 uint8}
{224×224 uint8}
{224×224 uint8}
{224×224 uint8}
{224×224 uint8}
{224×224 uint8}
{224×224 uint8}
{224×224 uint8}
{224×224 uint8}
{224×224 uint8}
{224×224 uint8}
:

Más respuestas (0)

Categorías

Más información sobre Image Data Workflows en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by