How to make a ResNet network with more than 3 channels?
This is in relation to the move from LayerGraphs, trainNetwork, and resnetLayers to dlnetworks, trainnet, and resnetNetwork.
I have a dataset consisting of 125×125 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 the training data
load("dataset.mat", "traindata");
traindata
%Train a ResNet LayerGraph using the old functions
imageSize = [125 125 8];
numClasses = 2;
layers = resnetLayers(imageSize,numClasses);
opts = trainingOptions("adam",…
"ExecutionEnvironment","cpu",…
"InitialLearnRate",0.0001,…
"MaxEpochs",1);
trainedNetwork = trainNetwork(traindata,layers,opts)
%Try to train a ResNet dlnetwork with the new functions, get an error
dlresnet = resnetNetwork(imageSize,numClasses);
dlresnet = initialize(dlresnet);
trainedDlnetwork = trainnet(traindata,dlresnet,"crossentropy",opts)This is in relation to the move from LayerGraphs, trainNetwork, and resnetLayers to dlnetworks, trainnet, and resnetNetwork.
I have a dataset consisting of 125×125 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 the training data
load("dataset.mat", "traindata");
traindata
%Train a ResNet LayerGraph using the old functions
imageSize = [125 125 8];
numClasses = 2;
layers = resnetLayers(imageSize,numClasses);
opts = trainingOptions("adam",…
"ExecutionEnvironment","cpu",…
"InitialLearnRate",0.0001,…
"MaxEpochs",1);
trainedNetwork = trainNetwork(traindata,layers,opts)
%Try to train a ResNet dlnetwork with the new functions, get an error
dlresnet = resnetNetwork(imageSize,numClasses);
dlresnet = initialize(dlresnet);
trainedDlnetwork = trainnet(traindata,dlresnet,"crossentropy",opts) This is in relation to the move from LayerGraphs, trainNetwork, and resnetLayers to dlnetworks, trainnet, and resnetNetwork.
I have a dataset consisting of 125×125 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 the training data
load("dataset.mat", "traindata");
traindata
%Train a ResNet LayerGraph using the old functions
imageSize = [125 125 8];
numClasses = 2;
layers = resnetLayers(imageSize,numClasses);
opts = trainingOptions("adam",…
"ExecutionEnvironment","cpu",…
"InitialLearnRate",0.0001,…
"MaxEpochs",1);
trainedNetwork = trainNetwork(traindata,layers,opts)
%Try to train a ResNet dlnetwork with the new functions, get an error
dlresnet = resnetNetwork(imageSize,numClasses);
dlresnet = initialize(dlresnet);
trainedDlnetwork = trainnet(traindata,dlresnet,"crossentropy",opts) machine learning, resnet, computer vision MATLAB Answers — New Questions