How to change the input size in first layer of Resnet?
4 views (last 30 days)
Show older comments
I have sequential data (Signal dataset) which shape is 1024x1, and I want to train that on resnet by changing the input in first layer.
I have tried below link but its not editable.
1 Comment
Answers (2)
Chunru
on 22 Jul 2022
Change input layer may requires new training (not transfer learning):
nresnet = resnet50;
n = [imageInputLayer([112 112 3]); nresnet.Layers(2:end)]; % specify new size
n
2 Comments
Fernando Perez
on 22 Jul 2022
Thanks,
However, my code is full of bugs. I'm trying to use my own data with one of the resnet examples but I'm facing all sorts of issues with functions I dont understant. For instance the the countEachLabel function gives only 0's, my label images look black and deeplabv3plusLayers still produces a wrong size error.
Is there any example with generic data sizes and number of classes? The tutorial in matlab does not takes you through what to do if your data is monochrome and you only have two classes.
Chunru
on 22 Jul 2022
If you want to use resnet without retraining or transfer learning, the best approach is to resize your input image to be the same size of resnet input layer. You can change the final layers for transfer learning.
Harsh
on 3 May 2024
Edited: Harsh
on 3 May 2024
Hi,
From what I can gather, you are trying to change the first layer of the resnet50 model in MATLAB.
"replaceLayer" method can also be used here, here's an example on how to use the "replaceLayer" function:
net = resnet50;
lgraph = layerGraph(net)
firstLayer = lgraph.Layers(1);
inputLayer = imageInputLayer([28 28 1]);
lgraph = replaceLayer(lgraph,firstLayer.Name,inputLayer)
Please refer to the following link for more information on "replaceLayer":
I hope this helps, thanks!
0 Comments
See Also
Categories
Find more on Image Data Workflows in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!