Beispiel #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
         );
 }
Beispiel #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);
        }
Beispiel #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
         );
 }
Beispiel #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;
        }