MyCaffe  1.12.2.41
Deep learning software for Windows C# programmers.
MathLayer.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{
16 public class MathLayer<T> : NeuronLayer<T>
17 {
28 : base(cuda, log, p)
29 {
31 }
32
38 public override void LayerSetUp(BlobCollection<T> colBottom, BlobCollection<T> colTop)
39 {
40 base.LayerSetUp(colBottom, colTop);
41 }
42
52 protected override void forward(BlobCollection<T> colBottom, BlobCollection<T> colTop)
53 {
54 int nCount = colBottom[0].count();
55 long hBottomData = colBottom[0].gpu_data;
56 long hTopData = colTop[0].mutable_gpu_data;
57
58 m_cuda.math_fwd(nCount, hBottomData, hTopData, m_param.math_param.function);
59 }
60
72 protected override void backward(BlobCollection<T> colTop, List<bool> rgbPropagateDown, BlobCollection<T> colBottom)
73 {
74 if (!rgbPropagateDown[0])
75 return;
76
77 int nCount = colBottom[0].count();
78 long hTopData = colTop[0].gpu_data;
79 long hTopDiff = colTop[0].gpu_diff;
80 long hBottomDiff = colBottom[0].mutable_gpu_diff;
81 long hBottomData = colBottom[0].gpu_data;
82
83 m_cuda.math_bwd(nCount, hTopDiff, hTopData, hBottomDiff, hBottomData, m_param.math_param.function);
84 }
85 }
86}
The Log class provides general output in text form.
Definition: Log.cs:13
The BlobCollection contains a list of Blobs.
The CudaDnn object is the main interface to the Low-Level Cuda C++ DLL.
Definition: CudaDnn.cs:969
LayerParameter m_param
Specifies the LayerParameter describing the Layer.
Definition: Layer.cs:47
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
The MathLayer which computes various mathematical functions of the input. This layer is initialized w...
Definition: MathLayer.cs:17
override void LayerSetUp(BlobCollection< T > colBottom, BlobCollection< T > colTop)
Setup the layer.
Definition: MathLayer.cs:38
override void backward(BlobCollection< T > colTop, List< bool > rgbPropagateDown, BlobCollection< T > colBottom)
Computes the error gradient w.r.t. the MATH function value inputs.
Definition: MathLayer.cs:72
MathLayer(CudaDnn< T > cuda, Log log, LayerParameter p)
The MathLayer constructor.
Definition: MathLayer.cs:27
override void forward(BlobCollection< T > colBottom, BlobCollection< T > colTop)
Forward computation
Definition: MathLayer.cs:52
The NeuronLayer is an interface for layers that take one blob as input (x) and produce only equally-s...
Definition: NeuronLayer.cs:22
Specifies the base parameter for all layers.
MathParameter math_param
Returns the parameter set when initialized with LayerType.MATH
LayerType
Specifies the layer type.
MyCaffe.common.MATH_FUNCTION function
Get/set the function to run.
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