vlfeat / autonn

A fast and expressive Matlab/MatConvNet deep learning API, with native automatic differentiation
89 stars 35 forks source link

Insert Layers #34

Closed wajahat57 closed 6 years ago

wajahat57 commented 6 years ago

Hi

Sorry for being so lame, but I am migrating from SimpleNN directly to AutoNN and don't have much knowledge of objected oriented programming either.

With a compiled autoNN network, is it possible to insert layers, such as adding dropouts, or removing pooling layers etc?

If not, then is the only way around is to recreate another network (using Layer.create() ) with parameters copied from original one where required?

Best Regards Wajahat

ryanwebster90 commented 6 years ago

With a compiled autoNN network, is it possible to insert layers, such as adding dropouts, or removing pooling layers etc?

Editing a network should happen before compilation. So, if you'd like to convert from SimpleNN to AutoNN and then add layers, you could use Layer.fromCompiledNet, e.g.

% convert a SimpleNN to AutoNN
net = Net(simple_nn_net);

% decompile into layers
last_layer = Layer.fromCompiledNet(net);

all_layers = last_layer.find();

As for layer insertion, it should definitely be possibly, something like this might work

% append relu onto insert_layer
insert_layer = vl_nnrelu(prev_layer);

% fix inputs of subsequent layers
next_layer.inputs{1} = insert_layer;

where "prev_layer" is the desired layer for insertion. Then recompile the network after the network has been modified.