pixel_shuffle.hpp
Go to the documentation of this file.
1 
13 #ifndef MLPACK_METHODS_ANN_LAYER_PIXEL_SHUFFLE_HPP
14 #define MLPACK_METHODS_ANN_LAYER_PIXEL_SHUFFLE_HPP
15 
16 #include <mlpack/prereqs.hpp>
17 
18 namespace mlpack {
19 namespace ann {
20 
45 template <
46  typename InputDataType = arma::mat,
47  typename OutputDataType = arma::mat
48 >
50 {
51  public:
53  PixelShuffle();
54 
65  PixelShuffle(const size_t upscaleFactor,
66  const size_t height,
67  const size_t width,
68  const size_t size);
69 
76  template<typename eT>
77  void Forward(const arma::Mat<eT>& input, arma::Mat<eT>& output);
78 
86  template<typename eT>
87  void Backward(const arma::Mat<eT>& input,
88  const arma::Mat<eT>& gy,
89  arma::Mat<eT>& g);
90 
92  OutputDataType const& OutputParameter() const { return outputParameter; }
94  OutputDataType& OutputParameter() { return outputParameter; }
95 
97  OutputDataType const& Delta() const { return delta; }
99  OutputDataType& Delta() { return delta; }
100 
102  size_t UpscaleFactor() const { return upscaleFactor; }
103 
105  size_t& UpscaleFactor() { return upscaleFactor; }
106 
108  size_t InputHeight() const { return height; }
109 
111  size_t& InputHeight() { return height; }
112 
114  size_t InputWidth() const { return width; }
115 
117  size_t& InputWidth() { return width; }
118 
120  size_t InputChannels() const { return size; }
121 
123  size_t& InputChannels() { return size; }
124 
126  size_t OutputHeight() const { return outputHeight; }
127 
129  size_t OutputWidth() const { return outputWidth; }
130 
132  size_t OutputChannels() const { return sizeOut; }
133 
137  template<typename Archive>
138  void serialize(Archive& ar, const unsigned int /* version */);
139 
140  private:
142  OutputDataType delta;
143 
145  OutputDataType outputParameter;
146 
148  size_t upscaleFactor;
149 
151  size_t height;
152 
154  size_t width;
155 
157  size_t size;
158 
160  size_t batchSize;
161 
163  size_t outputHeight;
164 
166  size_t outputWidth;
167 
169  size_t sizeOut;
170 
172  bool reset;
173 }; // class PixelShuffle
174 
175 } // namespace ann
176 } // namespace mlpack
177 
178 // Include implementation.
179 #include "pixel_shuffle_impl.hpp"
180 
181 #endif
size_t OutputHeight() const
Get the output image height.
size_t InputChannels() const
Get the number of input channels.
size_t OutputChannels() const
Get the number of output channels.
Linear algebra utility functions, generally performed on matrices or vectors.
void serialize(Archive &ar, const unsigned int)
Serialize the layer.
The core includes that mlpack expects; standard C++ includes and Armadillo.
size_t UpscaleFactor() const
Get the upscale factor.
void Backward(const arma::Mat< eT > &input, const arma::Mat< eT > &gy, arma::Mat< eT > &g)
Ordinary feed backward pass of the PixelShuffle layer.
size_t & UpscaleFactor()
Modify the upscale factor.
OutputDataType const & OutputParameter() const
Get the output parameter.
Implementation of the PixelShuffle layer.
OutputDataType const & Delta() const
Get the delta.
size_t & InputWidth()
Modify the input image width.
size_t InputWidth() const
Get the input image width.
size_t & InputHeight()
Modify the input image height.
size_t InputHeight() const
Get the input image height.
void Forward(const arma::Mat< eT > &input, arma::Mat< eT > &output)
Ordinary feed forward pass of the PixelShuffle layer.
size_t OutputWidth() const
Get the output image width.
OutputDataType & Delta()
Modify the delta.
OutputDataType & OutputParameter()
Modify the output parameter.
size_t & InputChannels()
Modify the number of input channels.
PixelShuffle()
Create the PixelShuffle object.