class NN::Affine
Attributes
d_bias[R]
d_weight[R]
Public Class Methods
new(nn, index)
click to toggle source
# File lib/nn.rb, line 287 def initialize(nn, index) @nn = nn @index = index @d_weight = nil @d_bias = nil end
Public Instance Methods
backward(dout)
click to toggle source
# File lib/nn.rb, line 299 def backward(dout) @d_weight = @x.transpose.dot(dout) if @nn.weight_decay > 0 dridge = @nn.weight_decay * @nn.weights[@index] @d_weight += dridge end @d_bias = dout.sum(0) dout.dot(@nn.weights[@index].transpose) end
forward(x)
click to toggle source
# File lib/nn.rb, line 294 def forward(x) @x = x @x.dot(@nn.weights[@index]) + @nn.biases[@index] end