How to change the input size in first layer of Resnet?
8 次查看(过去 30 天)
显示 更早的评论
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.
回答(2 个)
Chunru
2022-7-22
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 个评论
Fernando Perez
2022-7-22
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
2022-7-22
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
2024-5-3
编辑:Harsh
2024-5-3
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 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Image Data Workflows 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!