Class: Chainer::Summary
- Inherits:
-
Object
- Object
- Chainer::Summary
- Defined in:
- lib/chainer/reporter.rb
Instance Method Summary collapse
-
#add(value) ⇒ Object
Adds a scalar value.
-
#compute_mean ⇒ Object
Computes the mean.
-
#initialize ⇒ Summary
constructor
A new instance of Summary.
-
#make_statistics ⇒ Object
Computes and returns the mean and standard deviation values.
Constructor Details
#initialize ⇒ Summary
Returns a new instance of Summary.
67 68 69 70 71 |
# File 'lib/chainer/reporter.rb', line 67 def initialize @x = 0 @x2 = 0 @n = 0 end |
Instance Method Details
#add(value) ⇒ Object
Adds a scalar value. Args:
value: Scalar value to accumulate.
76 77 78 79 80 |
# File 'lib/chainer/reporter.rb', line 76 def add(value) @x += value @x2 += value * value @n += 1 end |
#compute_mean ⇒ Object
Computes the mean.
83 84 85 |
# File 'lib/chainer/reporter.rb', line 83 def compute_mean @x.to_f / @n end |
#make_statistics ⇒ Object
Computes and returns the mean and standard deviation values. Returns:
array: Mean and standard deviation values.
90 91 92 93 94 95 |
# 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 |