MyCaffe  1.12.2.41
Deep learning software for Windows C# programmers.
InputLayer.cs
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
5using System.Threading.Tasks;
6using MyCaffe.basecode;
7using MyCaffe.common;
8using MyCaffe.param;
9
10namespace MyCaffe.layers
11{
21 public class InputLayer<T> : Layer<T>
22 {
32 : base(cuda, log, p)
33 {
35 }
36
42 public override void LayerSetUp(BlobCollection<T> colBottom, BlobCollection<T> colTop)
43 {
44 int nNumTop = colTop.Count;
46 int nNumShape = p.shape.Count();
47
49 m_log.CHECK(nNumShape == 0 || nNumShape == 1 || nNumShape == nNumTop, "Must specify 'shape' once, once per top blob, or not at all: " + nNumTop.ToString() + " top vs. " + nNumShape.ToString() + " shapes.");
50
51 if (nNumShape > 0)
52 {
53 for (int i = 0; i < nNumTop; i++)
54 {
55 int nShapeIdx = (p.shape.Count() == 1) ? 0 : i;
56 colTop[i].Reshape(p.shape[nShapeIdx], m_bUseHalfSize);
57 }
58 }
59
61 }
62
68 public override void Reshape(BlobCollection<T> colBottom, BlobCollection<T> colTop)
69 {
70 }
71
75 public override int ExactNumBottomBlobs
76 {
77 get { return 0; }
78 }
79
83 public override int MinTopBlobs
84 {
85 get { return 1; }
86 }
87
88
96 protected override void forward(BlobCollection<T> colBottom, BlobCollection<T> colTop)
97 {
98 }
99
101 protected override void backward(BlobCollection<T> colTop, List<bool> rgbPropagateDown, BlobCollection<T> colBottom)
102 {
103 }
104 }
105}
The Log class provides general output in text form.
Definition: Log.cs:13
void CHECK(bool b, string str)
Test a flag for true.
Definition: Log.cs:227
The BlobCollection contains a list of Blobs.
int Count
Returns the number of items in the collection.
void Reshape(int[] rgShape)
Reshapes all blobs in the collection to the given shape.
The CudaDnn object is the main interface to the Low-Level Cuda C++ DLL.
Definition: CudaDnn.cs:969
The InputLayer provides data to the Net by assigning top Blobs directly. This layer is initialized wi...
Definition: InputLayer.cs:22
override int ExactNumBottomBlobs
The InputLayer has no bottom Blobs and therefore returns 0.
Definition: InputLayer.cs:76
override int MinTopBlobs
Returns the minimum number of required top (output) Blobs: data
Definition: InputLayer.cs:84
override void Reshape(BlobCollection< T > colBottom, BlobCollection< T > colTop)
Reshape the bottom (input) and top (output) blobs.
Definition: InputLayer.cs:68
InputLayer(CudaDnn< T > cuda, Log log, LayerParameter p)
The InputLayer constructor.
Definition: InputLayer.cs:31
override void backward(BlobCollection< T > colTop, List< bool > rgbPropagateDown, BlobCollection< T > colBottom)
Not implemented - data Layers do not perform backward.
Definition: InputLayer.cs:101
override void forward(BlobCollection< T > colBottom, BlobCollection< T > colTop)
The forward computation - which is trivial.
Definition: InputLayer.cs:96
override void LayerSetUp(BlobCollection< T > colBottom, BlobCollection< T > colTop)
Setup the layer.
Definition: InputLayer.cs:42
An interface for the units of computation which can be composed into a Net.
Definition: Layer.cs:31
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
LayerParameter.LayerType m_type
Specifies the Layer type.
Definition: Layer.cs:35
bool m_bConvertTopOnFwd
Specifies whether or not the layer should convert the top on the forward pass when using half sized m...
Definition: Layer.cs:88
Specifies the parameters for the InputLayer.
List< BlobShape > shape
Define N shapes to set a shape for each top. Define 1 shape to set the same shape for every top....
Specifies the base parameter for all layers.
bool use_halfsize
Specifies whether or not to use half sized memory or not.
InputParameter input_param
Returns the parameter set when initialized with LayerType.INPUT
LayerType
Specifies the layer type.
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