コード例 #1
0
 public FlattenLayerBackprop(FlattenLayer unit)
 {
     _unit     = unit;
     _outgoing = new Matrix <float> [unit.Z];
     for (int i = 0; i < _outgoing.Length; i++)
     {
         _outgoing[i] = Matrix <float> .Build.Dense(unit.X, unit.Y);
     }
 }
コード例 #2
0
        public Vector <float> Compute(StatePair input, bool training)
        {
            // Forward propagate.
            var img = InputLayer.Compute(input.Spatial);

            for (int i = 0; i < ConvolutionalLayers.Length; i++)
            {
                img = SubSampleLayers[i].Compute(ConvolutionalLayers[i].Compute(img));
            }
            _vecp.left           = FlattenLayer.Compute(img);
            _vecp.right          = LinearHiddenLayer.Compute(VectorInput.Compute(input.Linear));
            IsOutputFromTraining = false;
            var res = OutputLayer.Compute(CombinationLayer.Compute(_vecp));

            if (ValuesComputed != null)
            {
                ValuesComputed(res, training);
            }
            return(res);
        }
コード例 #3
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);
 }