How to change the input size in first layer of Resnet?
조회 수: 10 (최근 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.
댓글 수: 1
답변 (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!