Search code examples
matlabdeep-learningvlfeatmatconvnetdeep-residual-networks

residual network cell content reference error on matconvnet


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 topic.

Any ideas are appreciated

Thanks in advance


Solution

  • If I remember correctly, ResNet uses DAGNN (i.e., the network is a directed acyclic graph). VGG is simplenn. So you can't use vl_simplenn_tidy for ResNet. The error is caused by accessing net.layers using {}. In DAGNN, you can only access layers by (), since it is a matlab struct array, instead of a cell array. That said, there are other differences between dagNN and simplenn. So you can't use vl_simplenn_tidy() on dagNN.