Info
此问题已关闭。 请重新打开它进行编辑或回答。
Error using reshape To RESHAPE the number of elements must not change in Matlab2016b
1 次查看(过去 30 天)
显示 更早的评论
hi I wrote these codes for classify Drone Images into 2 Objects:
imds=imageDatastore('C:\users\hossein\my documents\matlab\droneimagesfinal','fileextensions','.jpg');
target=[2;2;1;1;2;2;2;2;1;1;2;2;2;2;1;1;1;2;2;2;2;1;1;1;1;1;1;2;2;2;1;1;1;1;1;1;1;1;1;1;1;1;2;2;2;1;1;1;1;1;1;1;1;1;1;1;1;2;1;1;1;1;1;1;2;1;1;1;1;1;1;
1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;2;2;1;1;1;1;1;1;1;1;2;2;2;1;1;1;2;2;1;1;2;2;2;1;2;2;2;1;1;1;1;1;1;1;1;1;2;2;2;2;2;2;2;2;1;1;1;1;1;1;1;
1;1;1;1;1;1;1;1;2;2;2;2;2;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;2;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;2;2;2;1;1;1;1;1;1;1;1;1;1;1;
1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;2;2;2];
imds.Labels=target;
[testset,trainingset]= splitEachLabel(imds,0.3,'randomize');
tr_data=zeros(227,227,3,size(trainingset.Labels,1));
te_data=zeros(227,227,3,size(testset.Labels,1));
net=alexnet;
layer='fc7';
Te_F=[];
for i=1:size(testset.Labels,1)
img= readimage(testset,i);
I=zeros(227,227,3);
img=imresize(img,[227 227]);
I(:,:,1:3)=cat(3,img,img,img);
F=activations(net,I,layer);
F=reshape(F(1,1,:),1,4096);
Te_F=[Te_F,F];
end
Tr_F=[];
for i=1:size(trainingset.Labels,1)
img= readimage(trainingset,i);
I=zeros(227,227,3);
img=imresize(img,[227 227]);
I(:,:,1:3)=cat(3,img,img,img);
F=activations(net,I,layer);
F=reshape(F(1,1,:),1,4096);
Tr_F=[Tr_F,F];
end
but after run codes Matlab2016b says this Error: " Error using reshape
To RESHAPE the number of elements must not change."
Error in dronetest1 (line 24)
F=reshape(F(1,:,[]),1,4096);
please help me to fix this error.
回答(0 个)
此问题已关闭。
另请参阅
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!