MyCaffe  1.12.2.41
Deep learning software for Windows C# programmers.
Filler.cs
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
5using MyCaffe.basecode;
6using MyCaffe.param;
7using MyCaffe.common;
8
12namespace MyCaffe.fillers
13{
18 public abstract class Filler<T>
19 {
23 protected CudaDnn<T> m_cuda;
27 protected Log m_log;
32
39 public Filler(CudaDnn<T> cuda, Log log, FillerParameter p)
40 {
41 m_cuda = cuda;
42 m_log = log;
43 m_param = p;
44 }
45
50 public void Fill(Blob<T> b)
51 {
52 int nNum = (b.num_axes > 0) ? b.shape(0) : 1;
53 int nNumChannels = (b.num_axes > 1) ? b.shape(1) : 1;
54 int nHeight = (b.num_axes > 2) ? b.shape(2) : 1;
55 int nWidth = (b.num_axes > 3) ? b.shape(3) : 1;
56 Fill(b.count(), b.mutable_gpu_data, b.num_axes, nNum, nNumChannels, nHeight, nWidth);
57 }
58
59
70 public abstract void Fill(int nCount, long hMem, int nNumAxes = 1, int nNumOutputs = 1, int nNumChannels = 1, int nHeight = 1, int nWidth = 1);
71
79 public static Filler<T> Create(CudaDnn<T> cuda, Log log, FillerParameter p)
80 {
81 switch (p.type)
82 {
83 case "constant":
84 return new ConstantFiller<T>(cuda, log, p);
85
86 case "sequence":
87 return new SequenceFiller<T>(cuda, log, p);
88
89 case "gaussian":
90 return new GaussianFiller<T>(cuda, log, p);
91
92 case "uniform":
93 return new UniformFiller<T>(cuda, log, p);
94
95 case "positive_unitball":
96 return new PositiveUnitballFiller<T>(cuda, log, p);
97
98 case "xavier":
99 return new XavierFiller<T>(cuda, log, p);
100
101 case "msra":
102 return new MsraFiller<T>(cuda, log, p);
103
104 case "bilinear":
105 return new BilinearFiller<T>(cuda, log, p);
106
107 default:
108 log.FAIL("Unknown filler type: " + p.type);
109 return null;
110 }
111 }
112 }
113}
The Log class provides general output in text form.
Definition: Log.cs:13
void FAIL(string str)
Causes a failure which throws an exception with the desciptive text.
Definition: Log.cs:394
The Blob is the main holder of data that moves through the Layers of the Net.
Definition: Blob.cs:25
int num_axes
Returns the number of axes in the Blob.
Definition: Blob.cs:705
long mutable_gpu_data
Returns the data GPU handle used by the CudaDnn connection.
Definition: Blob.cs:1487
List< int > shape()
Returns an array where each element contains the shape of an axis of the Blob.
Definition: Blob.cs:684
int count()
Returns the total number of items in the Blob.
Definition: Blob.cs:739
The CudaDnn object is the main interface to the Low-Level Cuda C++ DLL.
Definition: CudaDnn.cs:969
Fills a Blob with coefficients for bilinear interpolation.
Fills a Blob with constant values x = c.
Abstract Filler class used to fill blobs with values.
Definition: Filler.cs:19
Filler(CudaDnn< T > cuda, Log log, FillerParameter p)
Constructor.
Definition: Filler.cs:39
void Fill(Blob< T > b)
Fill the blob with values based on the actual filler used.
Definition: Filler.cs:50
FillerParameter m_param
Specifies the filler parameters.
Definition: Filler.cs:31
static Filler< T > Create(CudaDnn< T > cuda, Log log, FillerParameter p)
Create a new Filler instance.
Definition: Filler.cs:79
CudaDnn< T > m_cuda
Specifies the CudaDnn instance used to communicate to the low-level Cuda Dnn DLL.
Definition: Filler.cs:23
abstract void Fill(int nCount, long hMem, int nNumAxes=1, int nNumOutputs=1, int nNumChannels=1, int nHeight=1, int nWidth=1)
Fill the memory with values based on the actual filler used.
Log m_log
Specifies the output log.
Definition: Filler.cs:27
Fills a Blob with Gaussian-distributed values .
Fills a Blob with values where is set inversely proportionla to number of incomming nodes,...
Definition: MsraFiller.cs:31
Fills a Blob with values such that .
Fills a Blob with a sequence of values x0 = c; x1 = c + 0.01...
Fills a Blob with uniformly distributed values
Fills a Blob with values where is set inversely proportional to number of incoming nodes,...
Definition: XavierFiller.cs:27
Specifies the filler parameters used to create each Filler.
string type
Specifies the type of filler to use.
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.fillers namespace contains all fillers including the Filler class.
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