MyCaffe  1.12.2.41
Deep learning software for Windows C# programmers.
CopyLayer.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{
15 public class CopyLayer<T> : Layer<T>
16 {
24 : base(cuda, log, p)
25 {
27 }
28
32 public override int ExactNumBottomBlobs
33 {
34 get { return 2; }
35 }
36
40 public override int ExactNumTopBlobs
41 {
42 get { return 0; }
43 }
44
46 public override void LayerSetUp(BlobCollection<T> colBottom, BlobCollection<T> colTop)
47 {
48 }
49
51 public override void Reshape(BlobCollection<T> colBottom, BlobCollection<T> colTop)
52 {
53 }
54
56 protected override void forward(BlobCollection<T> colBottom, BlobCollection<T> colTop)
57 {
58 m_log.CHECK_EQ(colBottom[0].count(), colBottom[1].count(), "The bottom(0) and bottom(1) must have the same count!");
59 m_cuda.copy(colBottom[0].count(), colBottom[0].gpu_data, colBottom[1].mutable_gpu_data);
60 }
61
70 protected override void backward(BlobCollection<T> colTop, List<bool> rgbPropagateDown, BlobCollection<T> colBottom)
71 {
72 m_log.CHECK_EQ(colBottom[0].count(), colBottom[1].count(), "The bottom(0) and bottom(1) must have the same count!");
73 m_cuda.copy(colBottom[1].count(), colBottom[1].gpu_diff, colBottom[0].mutable_gpu_diff);
74 }
75 }
76}
The Log class provides general output in text form.
Definition: Log.cs:13
void CHECK_EQ(double df1, double df2, string str)
Test whether one number is equal to another.
Definition: Log.cs:239
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 CopyLayer copies the src bottom to the dst bottom. The layer has no output.
Definition: CopyLayer.cs:16
override void Reshape(BlobCollection< T > colBottom, BlobCollection< T > colTop)
Not implemented - no reshape needed.
Definition: CopyLayer.cs:51
override int ExactNumTopBlobs
Returns 0 as this layer has no output.
Definition: CopyLayer.cs:41
override void LayerSetUp(BlobCollection< T > colBottom, BlobCollection< T > colTop)
Not implemented - no setup needed.
Definition: CopyLayer.cs:46
override int ExactNumBottomBlobs
Returns the minimum number of required bottom (input) Blobs: input.
Definition: CopyLayer.cs:33
override void forward(BlobCollection< T > colBottom, BlobCollection< T > colTop)
Not implemented - no output.
Definition: CopyLayer.cs:56
override void backward(BlobCollection< T > colTop, List< bool > rgbPropagateDown, BlobCollection< T > colBottom)
The backward computation merely sets the bottom diff to zero.
Definition: CopyLayer.cs:70
CopyLayer(CudaDnn< T > cuda, Log log, LayerParameter p)
The CopyLayer constructor.
Definition: CopyLayer.cs:23
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
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
Specifies the base parameter for all layers.
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