This is in relation to the move from LayerGraphs, trainNetwork, and resnetLayers to dlnetworks, trainnet, and resnetNetwork.
I have a dataset consisting of 125x125 images, with 8 pixel channels instead of the usual 3 for RGB. With the older resnetLayers (which creates a ResNet LayerGraph) and trainNetwork, I was able to store this data as cells in a table and train with that. However, resnetLayers and trainNetwork are no longer recommended by MATLAB, and they recommend using resnetNetwork (which creates a ResNet dlnetwork) and trainnet instead. I want to keep up with the more modern and supported implementations, so I tried rewriting my code to use these, but I run into a problem where it seems trainnet won't accept this format of data anymore, and I haven't yet found a way to make it work. How should I go about passing this data to trainnet?
load("dataset.mat", "traindata");
traindata
traindata =
Features Response
__________________ __________
{125x125x8 double} Signal
{125x125x8 double} Background
{125x125x8 double} Background
{125x125x8 double} Background
{125x125x8 double} Signal
{125x125x8 double} Background
{125x125x8 double} Signal
layers = resnetLayers(imageSize,numClasses);
opts = trainingOptions("adam",...
"ExecutionEnvironment","cpu",...
"InitialLearnRate",0.0001,...
trainedNetwork = trainNetwork(traindata,layers,opts)
Initializing input data normalization.
|========================================================================================|
| Epoch | Iteration | Time Elapsed | Mini-batch | Mini-batch | Base Learning |
| | | (hh:mm:ss) | Accuracy | Loss | Rate |
|========================================================================================|
| 1 | 1 | 00:00:00 | 28.57% | 0.8097 | 1.0000e-04 |
|========================================================================================|
Training finished: Max epochs completed.
trainedNetwork =
DAGNetwork with properties:
Layers: [177x1 nnet.cnn.layer.Layer]
Connections: [192x2 table]
InputNames: {'input'}
OutputNames: {'output'}
dlresnet = resnetNetwork(imageSize,numClasses);
dlresnet = initialize(dlresnet);
trainedDlnetwork = trainnet(traindata,dlresnet,"crossentropy",opts)
Error using trainnet (line 46)
For table input, the data must be feature data and the network must have a single input and a single output.