MyCaffe  1.12.2.41
Deep learning software for Windows C# programmers.
MsraFiller.cs
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
5using MyCaffe.basecode;
6using MyCaffe.param;
7using MyCaffe.common;
8
9namespace MyCaffe.fillers
10{
30 public class MsraFiller<T> : Filler<T>
31 {
39 : base(cuda, log, p)
40 {
41 }
42
53 public override void Fill(int nCount, long hMem, int nNumAxes = 1, int nNumOutputs = 1, int nNumChannels = 1, int nHeight = 1, int nWidth = 1)
54 {
55 m_log.CHECK(nCount > 0, "There is no data to fill!");
56
57 int nFanIn = nCount / nNumOutputs;
58 // Compatibility with ND blobs
59 int nFanOut = nNumAxes > 1 ?
60 nCount / nNumChannels :
61 nCount;
62 double dfN = nFanIn; // default to fan_in
63
65 dfN = (nFanIn + nFanOut) / 2.0;
67 dfN = nFanOut;
68
69 double dfStd = Math.Sqrt(2.0 / dfN);
70 double dfMean = 0;
71 T fStd = (T)Convert.ChangeType(dfStd, typeof(T));
72 T fMean = (T)Convert.ChangeType(dfMean, typeof(T));
73 m_cuda.rng_gaussian(nCount, fMean, fStd, hMem);
74
75 m_log.CHECK_EQ(-1, m_param.sparse, "Sparsity not supported by this Filler.");
76 }
77 }
78}
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
void CHECK_EQ(double df1, double df2, string str)
Test whether one number is equal to another.
Definition: Log.cs:239
The CudaDnn object is the main interface to the Low-Level Cuda C++ DLL.
Definition: CudaDnn.cs:969
Abstract Filler class used to fill blobs with values.
Definition: Filler.cs:19
FillerParameter m_param
Specifies the filler parameters.
Definition: Filler.cs:31
CudaDnn< T > m_cuda
Specifies the CudaDnn instance used to communicate to the low-level Cuda Dnn DLL.
Definition: Filler.cs:23
Log m_log
Specifies the output log.
Definition: Filler.cs:27
Fills a Blob with values where is set inversely proportionla to number of incomming nodes,...
Definition: MsraFiller.cs:31
MsraFiller(CudaDnn< T > cuda, Log log, FillerParameter p)
Constructor.
Definition: MsraFiller.cs:38
override 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 random numbers from a MSRA distribution.
Definition: MsraFiller.cs:53
Specifies the filler parameters used to create each Filler.
int sparse
Specifies the sparcity value to use with the 'guassian' filler.
VarianceNorm
Defines the variance normalization.
VarianceNorm variance_norm
Specifies the variance normalization method to use with the 'xavier' and 'mrsa' fillers.
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