Index exceeds the number of array elements (1).
    조회 수: 3 (최근 30일)
  
       이전 댓글 표시
    
I faced this error  after performing some changes on the code. Any advices?
lgraph = yolov2Layers([128 128 3],numClasses,Anchors,lgraph,'relu_6');
Error using yolov2Layers>iReplaceImageInputLayer (line 298)
Index exceeds the number of array elements (1).
Error in yolov2Layers (line 112)
    lgraph = iReplaceImageInputLayer(lgraph,params.ImageSize);
function lgraph = iReplaceImageInputLayer(lgraph,imageSize)
% Replace input size in image input layer.
    idx = arrayfun(@(x)isa(x,'nnet.cnn.layer.ImageInputLayer'),...
        lgraph.Layers);
    imageInputIdx = find(idx,1,'first');
    imageInput =  vision.internal.cnn.utils.updateImageLayerInputSize(...
        lgraph.Layers(imageInputIdx), imageSize);
    lgraph = replaceLayer(lgraph,lgraph.Layers(imageInputIdx).Name,...
        imageInput);
    % Validate that replaced layer does not cause any issue.
    analysis = nnet.internal.cnn.analyzer.NetworkAnalyzer(lgraph);
    analysis.applyConstraints();
    if any(isnan(analysis.LayerAnalyzers(2,1).Outputs.Size{1}))
        error(message('vision:yolo:InvalidLayerSize', ... 
             mat2str(analysis.LayerAnalyzers(2,1).Inputs.Size{1}),...
             mat2str([analysis.LayerAnalyzers(2,1).Inputs.Size{1}(1:2),...
             analysis.LayerAnalyzers(2,1).Learnables.Size{1}(3)])));
    end
end
댓글 수: 0
답변 (1개)
  Sai Sri Pathuri
    
 2020년 7월 10일
        This error generally occurs when you access the index that is not present (or) more than the number of elements
For example,
A = [1,2,3,4,5,6];
If you try to access the 7th element of A, it gives this error including in bracket the actual number of elements in the array, which is 6 here
A(7)
Index exceeds the number of array elements (6).
댓글 수: 0
참고 항목
카테고리
				Help Center 및 File Exchange에서 Matrix Indexing에 대해 자세히 알아보기
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!