Azzera filtri
Azzera filtri

Info

Questa domanda è chiusa. Riaprila per modificarla o per rispondere.

Error using reshape To RESHAPE the number of elements must not change in Matlab2016b

1 visualizzazione (ultimi 30 giorni)
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.
  4 Commenti
seyed hosein alhoseiny
seyed hosein alhoseiny il 2 Apr 2019
Also In WorkSpace Section Of Matlab, Output Variables calculated incorrectly
I Attach WorkSpace Section Image for My codes in this Comment.
Please See WorkSpace Section Image Dronetest2.jpg
seyed hosein alhoseiny
seyed hosein alhoseiny il 2 Apr 2019
for example In WorkSpace Section in Above Image Variable F must be Vector 1*4096 single
that in Above Image F calculated incorrectly equal to -0.4052
also Tr_F variable Must be 191*4096 single (Training data are 191 Number)
Te_F Variable Must be 82*4096 single (Test data are 82 Number)
I guess All of My codes Must modify
and Please See Errors For Last Lines Of codes for Accuracy Of model.

Risposte (0)

Questa domanda è chiusa.

Prodotti

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by