Example #1
0
 public MeanPoolLayerBackprop(MeanPoolLayer unit)
 {
     _unit     = unit;
     _outgoing = new Matrix <float> [unit.Prev.ChannelCount];
     for (int i = 0; i < _outgoing.Length; i++)
     {
         _outgoing[i] = Matrix <float> .Build.Dense(unit.Prev.SideLength, unit.Prev.SideLength);
     }
     _ones = Matrix <float> .Build.Dense(unit.PoolSize, unit.PoolSize, 1f);
 }
Example #2
0
 public ConvolutionalNetwork(int matsize, int vecsize, int depth, int labels, params CNNArgs[] args)
 {
     _matsize               = matsize;
     _vecsize               = vecsize;
     _depth                 = depth;
     _labels                = labels;
     _args                  = args;
     InputLayer             = new SpatialLayer(matsize, depth);
     ConvolutionalLayers    = new ConvolutionalLayer[args.Length];
     SubSampleLayers        = new MeanPoolLayer[args.Length];
     ConvolutionalLayers[0] = new ConvolutionalLayer(args[0].FilterSize, args[0].FilterCount, args[0].Stride, InputLayer, Functions.Rectifier2D);
     SubSampleLayers[0]     = new MeanPoolLayer(args[0].PoolLayerSize, ConvolutionalLayers[0]);
     for (int i = 1; i < args.Length; i++)
     {
         ConvolutionalLayers[i] = new ConvolutionalLayer(args[i].FilterSize, args[i].FilterCount, args[i].Stride, SubSampleLayers[i - 1], Functions.Rectifier2D);
         SubSampleLayers[i]     = new MeanPoolLayer(args[i].PoolLayerSize, ConvolutionalLayers[i]);
     }
     FlattenLayer      = new FlattenLayer(SubSampleLayers[SubSampleLayers.Length - 1]);
     VectorInput       = new InputLayer(vecsize);
     LinearHiddenLayer = new DenseLayer(vecsize, VectorInput, Functions.Sigmoid);
     CombinationLayer  = new TreeLayer(FlattenLayer.Size(), vecsize);
     OutputLayer       = new DenseLayer(labels, CombinationLayer, Functions.Identity);
 }