class Chainer::Summary

Public Class Methods

new() click to toggle source
# File lib/chainer/reporter.rb, line 67
def initialize
  @x = 0
  @x2 = 0
  @n = 0
end

Public Instance Methods

add(value) click to toggle source

Adds a scalar value. Args:

value: Scalar value to accumulate.
# File lib/chainer/reporter.rb, line 76
def add(value)
  @x += value
  @x2 += value * value
  @n += 1
end
compute_mean() click to toggle source

Computes the mean.

# File lib/chainer/reporter.rb, line 83
def compute_mean
  @x.to_f / @n
end
make_statistics() click to toggle source

Computes and returns the mean and standard deviation values. Returns:

array: Mean and standard deviation values.
# File lib/chainer/reporter.rb, line 90
def make_statistics
  mean = @x / @n
  var = @x2 / @n - mean * mean
  std = Math.sqrt(var)
  [mean, std]
end