This repository was archived by the owner on Jul 1, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +7
-8
lines changed Expand file tree Collapse file tree 2 files changed +7
-8
lines changed Original file line number Diff line number Diff line change @@ -86,25 +86,24 @@ public func categoricalHingeLoss<Scalar: TensorFlowFloatingPoint>(
86
86
return max ( Tensor ( 0 ) , negative - positive + Tensor( 1 ) )
87
87
}
88
88
89
- /// Helper function for Logcosh
89
+ // Helper function for Logcosh
90
90
@differentiable ( wrt: x)
91
- internal func logcosh < Scalar: TensorFlowFloatingPoint > (
91
+ fileprivate func logCosh < Scalar: TensorFlowFloatingPoint > (
92
92
x: Tensor < Scalar >
93
93
) -> Tensor < Scalar > {
94
- let y = Tensor < Scalar > ( [ 2 ] )
95
- return x + softplus( Tensor ( - 2 ) * x) - log( y)
94
+ return x + softplus( Tensor ( - 2 ) * x) - log( Tensor ( y) )
96
95
}
97
96
98
- /// Returns the Logcosh loss between predictions and expectations.
97
+ /// Returns the logarithm of the hyperbolic cosine of the error between predictions and expectations.
99
98
///
100
99
/// - Parameters:
101
100
/// - predicted: Predicted outputs from a neural network.
102
101
/// - expected: Expected values, i.e. targets, that correspond to the correct output.
103
102
@differentiable ( wrt: predicted)
104
- public func logcoshLoss < Scalar: TensorFlowFloatingPoint > (
103
+ public func logCoshLoss < Scalar: TensorFlowFloatingPoint > (
105
104
predicted: Tensor < Scalar > , expected: Tensor < Scalar >
106
105
) -> Tensor < Scalar > {
107
- return ( logcosh ( x: predicted - expected) ) . mean ( )
106
+ return ( logCosh ( x: predicted - expected) ) . mean ( )
108
107
}
109
108
110
109
/// Returns the Poisson loss between predictions and expectations.
Original file line number Diff line number Diff line change @@ -96,7 +96,7 @@ final class LossTests: XCTestCase {
96
96
assertElementsEqual ( expected: Tensor ( expectedLoss) , actual: loss)
97
97
}
98
98
99
- func testLogcoshLoss ( ) {
99
+ func testLogCoshLoss ( ) {
100
100
let predicted = Tensor < Float > ( [ 0.2 , 0.3 , 0.4 ] )
101
101
let expected = Tensor < Float > ( [ 1.0 , 4.0 , 3.0 ] )
102
102
let loss = logcoshLoss ( predicted: predicted, expected: expected)
You can’t perform that action at this time.
0 commit comments