MyCaffe  1.12.2.41
Deep learning software for Windows C# programmers.
ClipLayer.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{
20 public class ClipLayer<T> : NeuronLayer<T>
21 {
33 : base(cuda, log, p)
34 {
36 }
37
51 protected override void forward(BlobCollection<T> colBottom, BlobCollection<T> colTop)
52 {
53 long hBottomData = colBottom[0].gpu_data;
54 long hTopData = colTop[0].mutable_gpu_data;
55 int nCount = colBottom[0].count();
56 double dfMin = m_param.clip_param.min;
57 double dfMax = m_param.clip_param.max;
58
59 m_cuda.clip_fwd(nCount, hBottomData, hTopData, (T)Convert.ChangeType(dfMin, typeof(T)), (T)Convert.ChangeType(dfMax, typeof(T)));
60 }
61
83 protected override void backward(BlobCollection<T> colTop, List<bool> rgbPropagateDown, BlobCollection<T> colBottom)
84 {
85 if (rgbPropagateDown[0])
86 {
87 long hBottomData = colBottom[0].gpu_data;
88 long hTopDiff = colTop[0].gpu_diff;
89 long hBottomDiff = colBottom[0].mutable_gpu_diff;
90 int nCount = colBottom[0].count();
91 double dfMin = m_param.clip_param.min;
92 double dfMax = m_param.clip_param.max;
93
94 m_cuda.clip_bwd(nCount, hTopDiff, hBottomData, hBottomDiff, (T)Convert.ChangeType(dfMin, typeof(T)), (T)Convert.ChangeType(dfMax, typeof(T)));
95 }
96 }
97 }
98}
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
The ClipLayer provides a neuron layer that clips the data to fit within the [min,max] range....
Definition: ClipLayer.cs:21
ClipLayer(CudaDnn< T > cuda, Log log, LayerParameter p)
The ClipLayer constructor.
Definition: ClipLayer.cs:32
override void backward(BlobCollection< T > colTop, List< bool > rgbPropagateDown, BlobCollection< T > colBottom)
Computes the error gradient w.r.t. the Clip value inputs.
Definition: ClipLayer.cs:83
override void forward(BlobCollection< T > colBottom, BlobCollection< T > colTop)
Forward computation
Definition: ClipLayer.cs:51
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 NeuronLayer is an interface for layers that take one blob as input (x) and produce only equally-s...
Definition: NeuronLayer.cs:22
double min
Specifies the min value for the Clip activation function.
double max
Specifies the max value for the Clip activation function.
Specifies the base parameter for all layers.
ClipParameter clip_param
Returns the parameter set when initialized with LayerType.CLIP
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