vlfeat / matconvnet

MatConvNet: CNNs for MATLAB
Other
1.4k stars 753 forks source link

non-cell array object error for resnets #972

Open ycbilge opened 7 years ago

ycbilge commented 7 years ago

Hi all,

I am using mathconvnet 1.0 beta24. I can install and compile the toolbox correctly. When I follow the quickstart on the website(http://www.vlfeat.org/matconvnet/quick/); I start with;

>> untar('http://www.vlfeat.org/matconvnet/download/matconvnet-1.0-beta24.tar.gz') ;
>> cd matconvnet-1.0-beta24
>> run matlab/vl_compilenn ;

After that instead of imagenet-vgg-f model I want to use one of the resnet models so I continue with;

>> urlwrite(...
  'http://www.vlfeat.org/matconvnet/models/imagenet-resnet-50-dag.mat', ...
  'imagenet-resnet-50-dag.mat') ;
>> run matlab/vl_setupnn ;
>> net = load('imagenet-resnet-50-dag.mat') ;

It works fine up to this part, but when I run the following command;

>> net = vl_simplenn_tidy(net) ;

I get the following error;

Cell contents reference from a non-cell array object.

Error in vl_simplenn_tidy (line 47) layer = net.layers{l} ;

imagenet-vgg-f model works fine but when I try to use the resnet model I get the error. I don't know how to solve this issue. This is very important for me as I am a novice at matconvnets. Any ideas are appreciated Thanks in advance

jizhihang commented 6 years ago

do you solve this question? I have the same problem! I use the mathconvnet 1.0 beta25.

zainulabidin302 commented 6 years ago

Same problem, Has someone addressed the problem? matconvnet-1.0-beta25

zainulabidin302 commented 6 years ago
..... 

 insz = tnet.meta.normalization.imageSize(1:2);
  bigimSz = insz + tnet.meta.normalization.border;
  tnet.meta.normalization.cropSize = insz ./ bigimSz;
end

% copy layers
for l = 1:numel(net.layers)
  defaults = {'name', sprintf('layer%d', l), 'precious', false};
  layer = net.layers{l} ;

  % Ignore custom layers (e.g. for classes the `isfield` does not work)
  % The only interface requirement for custom layers is forward and
  % backward function.
  if strcmp(layer.type, 'custom')
    tnet.layers{l} = layer ;
    continue;
  end
....

vl_simplenn_tidy.m line 46 layer = net.layers{l} ; is giving the error i.e


Error in vl_simplenn_tidy (line 47)
  layer = net.layers{l} ;

Error in classification_google_net (line 5)
net = vl_simplenn_tidy(net) ;

Can anyone suggest a fix?

zainulabidin302 commented 6 years ago

>> net = load('imagenet-googlenet-dag.mat')
net = 
  struct with fields:
      vars: [1×154 struct]
    params: [1×128 struct]
    layers: [1×153 struct]
      meta: [1×1 struct]
>> net.layers
ans = 
  1×153 struct array with fields:
    name
    type
    inputs
    outputs
    params
    block
>> net.layers(1)
ans = 
  struct with fields:

       name: 'conv1'
       type: 'dagnn.Conv'
     inputs: {'data'}
    outputs: {'conv1'}
     params: {'conv1_filter'  'conv1_bias'}
      block: [1×1 struct]
>> net.layers{1}
Cell contents reference from a non-cell array object.
 >> class(net.layers)
ans =
    'struct'
>> 

I suspect that the model structure is changed too much for vl_simplenn_tidy.m to handle.

Simply changing net.layer1{1} to net.layer1(1) does not work because other errors for layer type will come and net.layers(index).type then can not be understood by vl_simplenn.m

Need help to make it work. Thanks

zainulabidin302 commented 6 years ago

I have downgraded to matconvnet-1.0-beta22 to beta22 and used a model from here http://www.vlfeat.org/matconvnet/models/beta22/ and still getting the same error, 😟 Not sure what is going wrong ...