Info
La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.
Error using reshape To RESHAPE the number of elements must not change in Matlab2016b
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Respuestas (0)
La pregunta está cerrada.
Ver también
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!