Class: DNN::Losses::SoftmaxCrossEntropy
- Defined in:
- lib/dnn/core/losses.rb
Instance Attribute Summary collapse
-
#eps ⇒ Float
Return the eps value.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(eps: 1e-7) ⇒ SoftmaxCrossEntropy
constructor
A new instance of SoftmaxCrossEntropy.
- #to_hash ⇒ Object
Methods inherited from Loss
Constructor Details
#initialize(eps: 1e-7) ⇒ SoftmaxCrossEntropy
Returns a new instance of SoftmaxCrossEntropy.
122 123 124 |
# File 'lib/dnn/core/losses.rb', line 122 def initialize(eps: 1e-7) @eps = eps end |
Instance Attribute Details
#eps ⇒ Float
Return the eps value.
111 112 113 |
# File 'lib/dnn/core/losses.rb', line 111 def eps @eps end |
Class Method Details
.from_hash(hash) ⇒ Object
113 114 115 |
# File 'lib/dnn/core/losses.rb', line 113 def self.from_hash(hash) SoftmaxCrossEntropy.new(eps: hash[:eps]) end |
.softmax(x) ⇒ Object
117 118 119 |
# File 'lib/dnn/core/losses.rb', line 117 def self.softmax(x) NMath.exp(x) / NMath.exp(x).sum(1).reshape(x.shape[0], 1) end |
Instance Method Details
#to_hash ⇒ Object
126 127 128 |
# File 'lib/dnn/core/losses.rb', line 126 def to_hash super(eps: @eps) end |