Esempio n. 1
0
 public void CalculateSoftmax(SoftMaxCostLayer layer)
 {
     Gpu.Launch(layer.MinibatchSize, 1).CalculateSoftmaxGPU(
         layer.InputsGPU,
         layer.Outputs.GPUArray,
         layer.Labels.GPUArray,
         layer.CorrectlyPredictedLabels.GPUArray,
         layer.Gradients.GPUArray,
         layer.Size
         );
 }
Esempio n. 2
0
        public SoftMaxCostLayer AddSoftmaxLayer(int size, string id = "")
        {
            var lastLayer = Layers.Last();

            if (lastLayer == null)
            {
                throw new Exception("There must be one or more layers in the network");
            }
            if (CostLayer != null)
            {
                throw new Exception("There is already a cost layer");
            }

            var fcLayer = new FullyConnectedLayer(_gpuModule, lastLayer, size, id: id + "_fc");

            Layers.Add(fcLayer);
            var smLayer = new SoftMaxCostLayer(_gpuModule, fcLayer, this.LabelLayer, id: id);

            Layers.Add(smLayer);
            CostLayer = smLayer;
            return(smLayer);
        }
Esempio n. 3
0
 public void CalculateSoftmax(SoftMaxCostLayer layer)
 {
     Gpu.Launch(layer.MinibatchSize, 1).CalculateSoftmaxGPU(
         layer.InputsGPU,
         layer.Outputs.GPUArray,
         layer.Labels.GPUArray,
         layer.CorrectlyPredictedLabels.GPUArray,
         layer.Gradients.GPUArray,
         layer.Size
         );
 }
Esempio n. 4
0
        public SoftMaxCostLayer AddSoftmaxLayer(int size, string id = "")
        {
            var lastLayer = Layers.Last();
            if (lastLayer == null) throw new Exception("There must be one or more layers in the network");
            if (CostLayer != null) throw new Exception("There is already a cost layer");

            var fcLayer = new FullyConnectedLayer(_gpuModule, lastLayer, size, id: id + "_fc");
            Layers.Add(fcLayer);
            var smLayer = new SoftMaxCostLayer(_gpuModule, fcLayer, this.LabelLayer, id: id);
            Layers.Add(smLayer);
            CostLayer = smLayer;
            return smLayer;
        }