channel_shuffle.hpp
Go to the documentation of this file.
1 
10 #ifndef MLPACK_METHODS_ANN_LAYER_CHANNEL_SHUFFLE_HPP
11 #define MLPACK_METHODS_ANN_LAYER_CHANNEL_SHUFFLE_HPP
12 
13 #include <mlpack/prereqs.hpp>
14 
15 namespace mlpack {
16 namespace ann {
17 
42 template <
43  typename InputDataType = arma::mat,
44  typename OutputDataType = arma::mat
45 >
47 {
48  public:
51 
60  ChannelShuffle(const size_t inRowSize,
61  const size_t inColSize,
62  const size_t depth,
63  const size_t groupCount);
64 
71  template<typename eT>
72  void Forward(const arma::Mat<eT>& input, arma::Mat<eT>& output);
73 
85  template<typename eT>
86  void Backward(const arma::Mat<eT>& /*input*/,
87  const arma::Mat<eT>& gradient,
88  arma::Mat<eT>& output);
89 
91  OutputDataType const& OutputParameter() const { return outputParameter; }
93  OutputDataType& OutputParameter() { return outputParameter; }
94 
96  OutputDataType const& Delta() const { return delta; }
98  OutputDataType& Delta() { return delta; }
99 
101  size_t const& InRowSize() const { return inRowSize; }
103  size_t& InRowSize() { return inRowSize; }
104 
106  size_t const& InColSize() const { return inColSize; }
108  size_t& InColSize() { return inColSize; }
109 
111  size_t const& InDepth() const { return depth; }
113  size_t& InDepth() { return depth; }
114 
116  size_t const& InGroupCount() const { return groupCount; }
118  size_t& InGroupCount() { return groupCount; }
119 
121  size_t InputShape() const
122  {
123  return inRowSize;
124  }
125 
129  template<typename Archive>
130  void serialize(Archive& ar, const uint32_t /* version */);
131 
132  private:
134  size_t inRowSize;
136  size_t inColSize;
138  size_t depth;
140  size_t groupCount;
142  size_t batchSize;
144  OutputDataType delta;
146  OutputDataType outputParameter;
147 }; // class ChannelShuffle
148 
149 } // namespace ann
150 } // namespace mlpack
151 
152 // Include implementation.
153 #include "channel_shuffle_impl.hpp"
154 
155 #endif
size_t InputShape() const
Get the shape of the input.
size_t const & InRowSize() const
Get the row size of the input.
size_t & InGroupCount()
Modify the number of groups the channels is divided into.
Linear algebra utility functions, generally performed on matrices or vectors.
void Forward(const arma::Mat< eT > &input, arma::Mat< eT > &output)
Forward pass through the layer.
The core includes that mlpack expects; standard C++ includes and Armadillo.
size_t const & InGroupCount() const
Get the number of groups the channels is divided into.
size_t const & InDepth() const
Get the depth of the input.
void serialize(Archive &ar, const uint32_t)
Serialize the layer.
size_t & InColSize()
Modify the column size of the input.
OutputDataType & OutputParameter()
Modify the output parameter.
size_t const & InColSize() const
Get the column size of the input.
size_t & InRowSize()
Modify the row size of the input.
OutputDataType const & OutputParameter() const
Get the output parameter.
OutputDataType const & Delta() const
Get the delta.
Definition and implementation of the Channel Shuffle Layer.
void Backward(const arma::Mat< eT > &, const arma::Mat< eT > &gradient, arma::Mat< eT > &output)
Ordinary feed backward pass of a neural network, calculating the function f(x) by propagating x backw...
size_t & InDepth()
Modify the depth of the input.
ChannelShuffle()
Create the Channel Shuffle object.
OutputDataType & Delta()
Modify the delta.