MyCaffe  1.12.2.41
Deep learning software for Windows C# programmers.
ParameterLayer.cs
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
5using MyCaffe.basecode;
6using MyCaffe.common;
7using MyCaffe.param;
8
9namespace MyCaffe.layers
10{
15 public class ParameterLayer<T> : NeuronLayer<T>
16 {
24 : base(cuda, log, p)
25 {
27 }
28
32 public override int ExactNumBottomBlobs
33 {
34 get { return 0; }
35 }
36
40 public override int ExactNumTopBlobs
41 {
42 get { return 1; }
43 }
44
50 public override void LayerSetUp(BlobCollection<T> colBottom, BlobCollection<T> colTop)
51 {
52 if (blobs.Count > 0)
53 {
54 m_log.WriteLine("Skipping parameter initialization.");
55 }
56 else
57 {
58 Blob<T> blob = new Blob<T>(m_cuda, m_log);
59 blob.Name = m_param.name;
61 m_colBlobs.Add(blob);
62 }
63
65
67 }
68
74 public override void Reshape(BlobCollection<T> colBottom, BlobCollection<T> colTop)
75 {
76 }
77
87 protected override void forward(BlobCollection<T> colBottom, BlobCollection<T> colTop)
88 {
89 colTop[0].ShareData(m_colBlobs[0]);
90 colTop[0].ShareDiff(m_colBlobs[0]);
91 }
92
99 protected override void backward(BlobCollection<T> colTop, List<bool> rgbPropagateDown, BlobCollection<T> colBottom)
100 {
101 }
102 }
103}
The Log class provides general output in text form.
Definition: Log.cs:13
void WriteLine(string str, bool bOverrideEnabled=false, bool bHeader=false, bool bError=false, bool bDisable=false)
Write a line of output.
Definition: Log.cs:80
The BlobCollection contains a list of Blobs.
void Reshape(int[] rgShape)
Reshapes all blobs in the collection to the given shape.
The Blob is the main holder of data that moves through the Layers of the Net.
Definition: Blob.cs:25
void Reshape(int nNum, int nChannels, int nHeight, int nWidth, bool? bUseHalfSize=null)
DEPRECIATED; use
Definition: Blob.cs:442
string Name
Get/set the name of the Blob.
Definition: Blob.cs:2184
The CudaDnn object is the main interface to the Low-Level Cuda C++ DLL.
Definition: CudaDnn.cs:969
Log m_log
Specifies the Log for output.
Definition: Layer.cs:43
LayerParameter m_param
Specifies the LayerParameter describing the Layer.
Definition: Layer.cs:47
bool m_bUseHalfSize
Specifies that the half size of the top (if any) should be converted to the base size.
Definition: Layer.cs:84
CudaDnn< T > m_cuda
Specifies the CudaDnn connection to Cuda.
Definition: Layer.cs:39
LayerParameter.LayerType m_type
Specifies the Layer type.
Definition: Layer.cs:35
BlobCollection< T > blobs
Returns the collection of learnable parameter Blobs for the Layer.
Definition: Layer.cs:875
BlobCollection< T > m_colBlobs
Specifies the learnable parameter Blobs of the Layer.
Definition: Layer.cs:55
The NeuronLayer is an interface for layers that take one blob as input (x) and produce only equally-s...
Definition: NeuronLayer.cs:22
The ParameterLayer passes its blob[0] data and diff to the top[0].
override int ExactNumTopBlobs
Returns the exact number of required top (output) Blobs: flatten
override void Reshape(BlobCollection< T > colBottom, BlobCollection< T > colTop)
Reshape the bottom (input) and top (output) blobs.
ParameterLayer(CudaDnn< T > cuda, Log log, LayerParameter p)
The ParameterLayer constructor.
override void LayerSetUp(BlobCollection< T > colBottom, BlobCollection< T > colTop)
Setup the layer.
override void forward(BlobCollection< T > colBottom, BlobCollection< T > colTop)
Pass the blob[0] through to the top[0].
override int ExactNumBottomBlobs
Returns the exact number of required bottom (input) Blobs: none.
override void backward(BlobCollection< T > colTop, List< bool > rgbPropagateDown, BlobCollection< T > colBottom)
Does nothing.
Specifies the base parameter for all layers.
ParameterParameter parameter_param
Returns the parameter set when initialized with LayerType.PARAMETER
string name
Specifies the name of this LayerParameter.
bool use_halfsize
Specifies whether or not to use half sized memory or not.
LayerType
Specifies the layer type.
BlobShape shape
Specifies the parameter shape.
The MyCaffe.basecode contains all generic types used throughout MyCaffe.
Definition: Annotation.cs:12
The MyCaffe.common namespace contains common MyCaffe classes.
Definition: BatchInput.cs:8
The MyCaffe.layers namespace contains all layers that have a solidified code base,...
Definition: LayerFactory.cs:15
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