MyCaffe  1.12.2.41
Deep learning software for Windows C# programmers.
NormalizationLayers.cs
1using MyCaffe.param;
2using System;
3using System.Collections.Generic;
4using System.Linq;
5using System.Text;
6using System.Threading.Tasks;
7
9{
10 class LRNLayerInfo : LayerInfo
11 {
12 public LRNLayerInfo(LayerParameter layer, VariableCollection inputs) : base(layer, inputs)
13 {
14 }
15
16 public override string Generate(GENERATE gen)
17 {
18 string strCode = "";
19 if (gen == GENERATE.DEFINITION)
20 strCode += " self." + m_layer.name + " = nn.LocalResponseNorm(size=" + m_layer.lrn_param.local_size.ToString() + ", alpha=" + m_layer.lrn_param.alpha.ToString() + ", beta=" + m_layer.lrn_param.beta.ToString() + ", k=" + m_layer.lrn_param.k.ToString() + ")" + Environment.NewLine;
21 else if (gen == GENERATE.INITWEIGHTS)
22 {
23 }
24 else
25 strCode += " " + m_outputs.AsText + " = self." + m_layer.name + "(" + m_inputs.AsText + ")" + Environment.NewLine;
26
27 return strCode;
28 }
29 }
30
31 class BatchNormLayerInfo : LayerInfo
32 {
33 public BatchNormLayerInfo(LayerParameter layer, VariableCollection inputs) : base(layer, inputs)
34 {
35 }
36
37 public override string Generate(GENERATE gen)
38 {
39 string strCode = "";
40 if (gen == GENERATE.DEFINITION)
41 strCode += " self." + m_layer.name + " = nn.BatchNorm2d(num_features=" + m_inputs[0].getCount(1).ToString() + ", eps=" + m_layer.batch_norm_param.eps.ToString() + ")" + Environment.NewLine;
42 else if (gen == GENERATE.INITWEIGHTS)
43 {
44 }
45 else if (gen == GENERATE.FORWARD)
46 strCode += " " + m_outputs.AsText + " = self." + m_layer.name + "(" + m_inputs.AsText + ")" + Environment.NewLine;
47
48 return strCode;
49 }
50 }
51
52 class LayerNormLayerInfo : LayerInfo
53 {
54 public LayerNormLayerInfo(LayerParameter layer, VariableCollection inputs) : base(layer, inputs)
55 {
56 }
57
58 public override string Generate(GENERATE gen)
59 {
60 string strCode = "";
61 if (gen == GENERATE.DEFINITION)
62 strCode += " self." + m_layer.name + " = nn.LayerNorm2d(num_features=" + m_inputs[0].getCount(2).ToString() + ", eps=" + m_layer.layer_norm_param.epsilon.ToString() + ")" + Environment.NewLine;
63 else if (gen == GENERATE.INITWEIGHTS)
64 {
65 }
66 else if (gen == GENERATE.FORWARD)
67 strCode += " " + m_outputs.AsText + " = self." + m_layer.name + "(" + m_inputs.AsText + ")" + Environment.NewLine;
68
69 return strCode;
70 }
71 }
72}
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