Unexpected connection and input errors after modifying neural networks
8 ビュー (過去 30 日間)
古いコメントを表示
CODE:
model4 = squeezenet;
numClasses = 2;
layersTransfer = [
net.Layers(1:end-3)
fullyConnectedLayer(numClasses, 'Name', 'fc')
softmaxLayer('Name', 'softmax')
classificationLayer('Name', 'output')
];
dataFolder = './larger_data/larger_PetImages';
categories = {'cat', 'dog'};
imds2 = imageDatastore(fullfile(dataFolder, categories), 'LabelSource', 'foldernames');
% Another program converts images in imageDatastore to 224 x 224 x 3
[larger_trainingSet, larger_validationSet] = splitEachLabel(imds, 0.75, 'randomized');
new_options = trainingOptions('adam', ...
'MiniBatchSize',10, ...
'MaxEpochs',10, ...
'InitialLearnRate',1e-3, ...
'Shuffle','every-epoch', ...
'ValidationData',larger_validationSet, ...
'ValidationFrequency',3, ...
'Verbose',false, ...
'Plots','training-progress');
[model4_predictor, info] = trainNetwork(larger_trainingSet, layersTransfer, new_options);
ERROR:
Error using trainNetwork
Invalid network.
Caused by:
Layer 'fire2-concat': Unconnected input. Each layer input must be connected to the output of another layer.
Layer 'fire2-expand3x3': Invalid input data. The number of channels of the input data (64) must match the layer's expected number of channels (16).
Layer 'fire3-concat': Unconnected input. Each layer input must be connected to the output of another layer.
Layer 'fire4-concat': Unconnected input. Each layer input must be connected to the output of another layer.
Layer 'fire5-concat': Unconnected input. Each layer input must be connected to the output of another layer.
Layer 'fire6-concat': Unconnected input. Each layer input must be connected to the output of another layer.
Layer 'fire7-concat': Unconnected input. Each layer input must be connected to the output of another layer.
Layer 'fire8-concat': Unconnected input. Each layer input must be connected to the output of another layer.
Layer 'fire9-concat': Unconnected input. Each layer input must be connected to the output of another layer.
COMMENT:
Similar errors were experienced when making any modifications to the final three layers of the GoogleNet CNN.
Any help would be greatly appreciated
0 件のコメント
採用された回答
Taylor
2024 年 3 月 21 日
The Deep Network Designer app has a useful Network Analyzer tool for just this type of issue. Open the app using deepNetworkDesigner, load layersTransfer from your workspace, and select "Analyze" on the top toolstrip. You should see a report like the one below. Looks like your approach to modifying the network for transfer learning reconfigured the connections in the network unexpectedly. I would recommend following the approach outlined here.
6 件のコメント
その他の回答 (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!