cbovar / ConvNetSharp

Deep Learning in C#

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

using Dropout

rick779 opened this issue · comments

Hi,
I would like to try adding a dropout layer but I get this error on Train method: Volume should have a Shape [1] to be converter to a System.Double. What did I do wrong? I would also like to know how to avoid using the dropout layer when I'm not in training (testing).
Many Thanks

Net<double> net
net.AddLayer(new InputLayer(28, 28, 1));

net.AddLayer(new ConvLayer(3, 3, 10) { Stride = 1, Pad = 2 });
net.AddLayer(new ReluLayer());
net.AddLayer(new PoolLayer(2, 2) { Stride = 1 });

net.AddLayer(new FullyConnLayer(10));
net.AddLayer(new ReluLayer());

net.AddLayer(new DropoutLayer(0.5));

net.AddLayer(new FullyConnLayer(2));
net.AddLayer(new SoftmaxLayer(2));


....
var outputVolume = BuilderInstance.Volume.From(flattenedOutput, new Shape(1, 1, 2, InputData.Count));
trainer.Train(inputVolume, outputVolume);  //error

Hi,
PR #133 should fix the exception. I've also added some basic unit tests to catch this next time.

Dropout layer knows if you are training or not. (See here). So there will not be any value dropped during inference.

thank you very much, great project