class Sabina::Layer::BaseLayer
Attributes
I[RW]
J[RW]
W[RW]
b[RW]
size[R]
Public Class Methods
new(size)
click to toggle source
# File lib/sabina/layer/base_layer.rb, line 6 def initialize(size) @size = size @f = ->(x){ 1.0 / (1.0 + Math.exp(-x)) } @f_ = ->(x){ @f[x]*(1.0 - @f[x]) } end
Public Instance Methods
activate(u_ary)
click to toggle source
An activation function
# File lib/sabina/layer/base_layer.rb, line 24 def activate(u_ary) u_ary.map { |u| @f[u] } end
activate_(u_ary)
click to toggle source
Differentiation of activation function
# File lib/sabina/layer/base_layer.rb, line 29 def activate_(u_ary) u_ary.map { |u| @f_[u] } end
init_weight()
click to toggle source
Initialize the weights of this layer.
# File lib/sabina/layer/base_layer.rb, line 13 def init_weight # (J, 1) @b = Matrix.columns([Array.new(@size) { 0.0 }]) # (J, I) @W = Array.new(@J) do Array.new(@I) { Sabina::Utils.box_muller } end.tap { |ary| break Matrix[*ary] } end