Class: DNN::Layers::MaxPool2D
- Defined in:
- lib/dnn/core/cnn_layers.rb
Instance Attribute Summary
Attributes inherited from Pool2D
Class Method Summary collapse
Instance Method Summary collapse
Methods inherited from Pool2D
#build, #initialize, #shape, #to_hash
Methods inherited from Layer
#build, #built?, #initialize, #prev_layer, #shape, #to_hash
Constructor Details
This class inherits a constructor from DNN::Layers::Pool2D
Class Method Details
Instance Method Details
#backward(dout) ⇒ Object
232 233 234 235 236 237 |
# File 'lib/dnn/core/cnn_layers.rb', line 232 def backward(dout) dmax = Xumo::SFloat.zeros(dout.size * @pool_size.reduce(:*)) dmax[@max_index] = dout.flatten dcol = dmax.reshape(dout.shape[0..2].reduce(:*), dout.shape[3] * @pool_size.reduce(:*)) super(dcol) end |
#forward(x) ⇒ Object
226 227 228 229 230 |
# File 'lib/dnn/core/cnn_layers.rb', line 226 def forward(x) col = super(x) @max_index = col.max_index(1) col.max(1).reshape(x.shape[0], *@out_size, x.shape[3]) end |