Hello,
As per my understanding, the “read” function of your datastore is returning a cell array with 1 column when it is expected to return a cell array with 3 columns and consequently you are facing an “Invalid Training Data” error.
The error occurred in the “C” cell array in the “testdata.mat” file. The second input to the network i.e. the second column of this “C” cell array contains the features as “double” type objects of [1X40] size. These should have been of the size [40X1] since the “featureInputLayer” of the defined network in “lgraph_1” has 40 features. You can rectify this by transposing each object in this cell array. Follow the below code snippet.
%Accessing the second column of "C" variable
CCol2=C(:,2);
%Creating a new cellarray and initialising it with the first transposed [40X1] array
NewCol2={(CCol2{1,1})'};
%Looping through the size of cell array and transposing every matrix
for i=2:900
NewCol2=[CWithNewCol2 ;{(CCol2{i,1})'}];
end
%Update the second column of "C" variable
C=[C(:,1) NewCol2 C(:,3)];
For training neural networks with multiple inputs, we would require the ”features” argument of the “trainNetwork” function to be of “combinedDatastore” or “transformedDatastore” type only. Therefore, you should first use the “transform” function to convert the “fileDatastore” object to “transformedDatastore” type. You can define a custom transformation function “rearrangeData” to be used to transform the “fileDatastore” to ensure the “read(datastore)” returns [MX3] cell array.
trainingDatastore = transform(filedatastore,@rearrangeData);
function out = rearrangeData(ds)
out = ds.C;
end
You can refer to the following documentation to understand more about the “trainNetwork” function and the types of “features” arguments allowed.
You can refer to the following question where a similar issue is answered.
I hope this helps!