lib/dnn/core/normalizations.rb in ruby-dnn-0.13.1 vs lib/dnn/core/normalizations.rb in ruby-dnn-0.13.2
- old
+ new
@@ -8,14 +8,10 @@
attr_reader :running_var
attr_reader :axis
attr_accessor :momentum
attr_accessor :eps
- def self.from_hash(hash)
- self.new(axis: hash[:axis], momentum: hash[:momentum])
- end
-
# @param [Integer] axis The axis to normalization.
# @param [Float] momentum Exponential moving average of mean and variance.
# @param [Float] eps Value to avoid division by zero.
def initialize(axis: 0, momentum: 0.9, eps: 1e-7)
super()
@@ -64,9 +60,13 @@
dxc - dmean / batch_size
end
def to_hash
super(axis: @axis, momentum: @momentum, eps: @eps)
+ end
+
+ def load_hash(hash)
+ initialize(axis: hash[:axis], momentum: hash[:momentum])
end
def get_params
{ gamma: @gamma, beta: @beta, running_mean: @running_mean, running_var: @running_var }
end