MyCaffe  1.12.2.41
Deep learning software for Windows C# programmers.
LossLayers.cs
1using MyCaffe.param;
2using System;
3using System.Collections.Generic;
4using System.Linq;
5using System.Text;
6using System.Threading.Tasks;
7
9{
10 class SoftmaxLossLayerInfo : SoftmaxLayerInfo
11 {
12 public SoftmaxLossLayerInfo(LayerParameter layer, VariableCollection inputs) : base(layer, inputs)
13 {
14 m_rgstrReturnValues.Add("loss", 1);
15 }
16
17 public override string Generate(GENERATE gen)
18 {
19 string strCode = "";
20
21 if (gen == GENERATE.DEFINITION)
22 {
23 strCode += " self.smx = nn.Softmax(dim=" + m_layer.softmax_param.axis.ToString() + ")" + Environment.NewLine;
24 strCode += " self." + m_layer.name + " = nn.CrossEntropyLoss()" + Environment.NewLine;
25 }
26 else if (gen == GENERATE.INITWEIGHTS)
27 {
28 }
29 else if (gen == GENERATE.FORWARD)
30 {
31 strCode += " smx1 = self.smx(" + m_inputs.AsText + ")" + Environment.NewLine;
32 strCode += " " + m_outputs.AsText + " = self." + m_layer.name + "(smx1, " + m_layer.bottom[1] + ")" + Environment.NewLine;
33 }
34
35 return strCode;
36 }
37 }
38
39}
Specifies the base parameter for all layers.
The MyCaffe.param namespace contains parameters used to create models.
The MyCaffe namespace contains the main body of MyCaffe code that closesly tracks the C++ Caffe open-...
Definition: Annotation.cs:12