Problem with the "trainNetwork" function of neural network toolbox
이전 댓글 표시
I'm trying to do a transfer learning using AlexNet in version R2016a. But when my code ran to the "trainNetwork" function, I received these error messages:
Undefined function 'apply' for input arguments of type 'single'.
Error in trainNetwork>iComputeAverageImage (line 209)
X = apply(augmentations, X);
Error in trainNetwork>iInitializeNetworkNormalizations
(line 190)
avgI = iComputeAverageImage(data, augmentations);
Error in trainNetwork (line 78)
trainedNet = iInitializeNetworkNormalizations(trainedNet,
X, Y, opts, precision);
Error in trainingCompositionData (line 68)
convnetTransfer = trainNetwork(imds,transLayers,optionsTransfer);
I think the problem is not from my code, because the variable "augmentation" is an empty array and the variable "X" is a 4-D single matrix, which is specified by the "trainNetwork" itself.
Furthermore, I tried to find the code of "apply" function by open(F4) it and MATLAB redirected the page to the "ImageTransform" class, below is the "apply" function part of the class:
methods(Sealed)
%------------------------------------------------------------------
% Applies an array of transforms to a batch of RGB or grayscale
% images.
%------------------------------------------------------------------
function y = apply(this, batch)
y = batch;
for i = 1:numel(this)
y = doTransform(this(i), y);
end
end
end
I think this one is the correct code. But according to the error message, it seems that MATLAB doesn't use this function but other "apply" function in executing time.
Did anyone encounter this problem too?
댓글 수: 3
Stefano Giorgi
2017년 1월 8일
I had the same issue doing transfer learning from alexnet provided in the image catecory classification example on matlab website. I solved it re-creating the input image layer:
layersTransfer(1)=imageInputLayer([227 227 3],'normalization','zerocenter')
Note thet I re-created it exactly as it was before. I don't know the reason but it seems that input image normalization part won't succeed if you don't re-create the input layer in transfer learning. Not too bad since you don't loose anything re-creating it. After thet I was able to train it, too bad that on my poor 2 GB GPU I ran out of memory with batch size > 2, so GPU is unfeasible for me. This is a bit strange because the original Alexnet was trained with a batch of 128 on 2x3Gb GPU. Is it matlab implementation a bit too much memory hungry?
Joss Knight
2017년 1월 12일
MATLAB is too memory hungry. This has been improved in a future release. 2 GB is still a bit restrictive for training AlexNet though, if the GPU is also driving the display.
Alam Noor
2018년 5월 1일
Stefano Giorgi, can you please help for error of Error using classify (line 122) Requires at least three arguments.
Error in AlexNet_1 (line 12) label=classify(net,pic);
답변 (2개)
Walter Roberson
2016년 10월 6일
0 개 추천
Try training on double precision values not single precision.
flysuya
2016년 12월 5일
0 개 추천
yes, I meet the same question. Do you find solution?
댓글 수: 2
Walter Roberson
2016년 12월 5일
What happened when you changed your data to double precision?
Roopam Gupta
2017년 12월 5일
it does not change the error
카테고리
도움말 센터 및 File Exchange에서 Deep Learning Toolbox에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!