class DNN::Layers::Mean
Attributes
axis[R]
keepdims[R]
Public Class Methods
new(axis: 0, keepdims: true)
click to toggle source
Calls superclass method
DNN::Layers::Layer::new
# File lib/dnn/core/layers/math_layers.rb, line 234 def initialize(axis: 0, keepdims: true) super() @axis = axis @keepdims = keepdims end
Public Instance Methods
backward_node(dy)
click to toggle source
# File lib/dnn/core/layers/math_layers.rb, line 251 def backward_node(dy) MathUtils.broadcast_to(dy, @x_shape) / @dim end
forward_node(x)
click to toggle source
# File lib/dnn/core/layers/math_layers.rb, line 240 def forward_node(x) @x_shape = x.shape if @axis @dim = x.shape[@axis] x.mean(axis: @axis, keepdims: true) else @dim = x.size x.mean end end
load_hash(hash)
click to toggle source
# File lib/dnn/core/layers/math_layers.rb, line 259 def load_hash(hash) initialize(axis: hash[:axis], keepdims: hash[:keepdims]) end
to_hash()
click to toggle source
Calls superclass method
DNN::Layers::Layer#to_hash
# File lib/dnn/core/layers/math_layers.rb, line 255 def to_hash super(axis: @axis, keepdims: @keepdims) end