matlab迁移学习训练数据集时报错
1、des_path="./picture/";
ds=imageDatastore(des_path,"IncludeSubfolders",true,"LabelSource","foldernames")
ds.Labels
2、I=readimage(ds,100)
imshow(I)
montage(ds)
3、[train,test]=splitEachLabel(ds,0.7,"randomized");
trainimage=augmentedImageDatastore([224 224],train,"ColorPreprocessing","gray2rgb")
testimage=augmentedImageDatastore([224 224],test,"ColorPreprocessing","gray2rgb")
4、先在googlnet测试,作为对比
net=googlenet;
pred=classify(net,testimage)
5、开始训练
opts=trainingOptions("sgdm","InitialLearnRate",0.001,"MaxEpochs",5,"MiniBatchSize",8)
[net1,info]=trainNetwork(trainimage,lgraph_3,opts)
6、训练结果图
plot(info,TrainingLoss)
7、testpred=classify(net1,testimage)
confusionchart(test.Labels,testpred)
1-4运行正常,第5项运行时报错
报错内容:
错误使用trainNetwork
Invalid training data.The output size (10) of the last layer does not match the number of classes of the responses (3).
尝试过doc trainNetwork / help trainNetwork
还是不太清楚解决办法