-
Notifications
You must be signed in to change notification settings - Fork 137
Update min(_:_:)
and max(_:_:)
gradients to match Python TensorFlow
#480
Conversation
@dan-zheng @rxwei This should be ready. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the prompt fix! 🙂
There appears to be one failure:
It's likely because @differentiable(wrt: logits)
public func sigmoidCrossEntropy<Scalar: TensorFlowFloatingPoint>(
logits: Tensor<Scalar>,
labels: Tensor<Scalar>,
reduction: @differentiable (Tensor<Scalar>) -> Tensor<Scalar> = _mean
) -> Tensor<Scalar> {
let maxLogitsWithZero = max(logits, Tensor(0)) // `max` called here
let result = log(1 + exp(-abs(logits)))
return reduction(maxLogitsWithZero - logits * labels + result)
} Could you please fix? Updating the expected value in the test should be good - validating the expected value against |
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @jon-tow for the many adjustments!
No problem @dan-zheng. Thanks for the guidance! |
Fixes #479