Class: DNN::Layers::Reshape

Inherits:
Layer
  • Object
show all
Defined in:
lib/dnn/core/layers.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Layer

#init, #prev_layer

Constructor Details

#initialize(shape) ⇒ Reshape

Returns a new instance of Reshape.



286
287
288
289
# File 'lib/dnn/core/layers.rb', line 286

def initialize(shape)
  @shape = shape
  @x_shape = nil
end

Instance Attribute Details

#shapeObject (readonly)

Returns the value of attribute shape.



284
285
286
# File 'lib/dnn/core/layers.rb', line 284

def shape
  @shape
end

Instance Method Details

#backward(dout) ⇒ Object



296
297
298
# File 'lib/dnn/core/layers.rb', line 296

def backward(dout)
  dout.reshape(@x_shape)
end

#forward(x) ⇒ Object



291
292
293
294
# File 'lib/dnn/core/layers.rb', line 291

def forward(x)
  @x_shape = x.shape
  x.reshape(*@shape)
end