Skip to content
This repository was archived by the owner on Jul 1, 2023. It is now read-only.

Reverting inference behavior for BatchNorm #426

Merged
merged 1 commit into from
Aug 8, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions Sources/TensorFlow/Layers/Normalization.swift
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,8 @@ public struct BatchNorm<Scalar: TensorFlowFloatingPoint>: Layer {
let inv = rsqrt(moments.variance + epsilon) * scale.reshaped(to: moments.variance.shape)
return (input - moments.mean) * inv + offset.reshaped(to: moments.mean.shape)
case .inference:
let scaleShape = runningVariance.value.shape
let offsetShape = runningMean.value.shape
let inv = rsqrt(runningVariance.value + epsilon) * scale.reshaped(to: scaleShape)
return (input - runningMean.value) * inv + offset.reshaped(to: offsetShape)
let inv = rsqrt(runningVariance.value + epsilon) * scale
return (input - runningMean.value) * inv + offset
}
}

Expand Down