Skip to content
This repository was archived by the owner on Apr 23, 2025. It is now read-only.

Change momentum and epsilon properties to scalars. #220

Merged
merged 1 commit into from
Nov 7, 2019
Merged
Show file tree
Hide file tree
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
5 changes: 1 addition & 4 deletions MiniGo/Models/GoModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,7 @@ struct ConvBN: Layer {
// TODO(jekbradbury): thread through bias and affine boolean arguments
// (behavior is correct for inference but this should be changed for training)
self.conv = Conv2D(filterShape: filterShape, strides: strides, padding: padding)
self.norm = BatchNorm(
featureCount: filterShape.3,
momentum: Tensor<Float>(0.95),
epsilon: Tensor<Float>(1e-5))
self.norm = BatchNorm(featureCount: filterShape.3, momentum: 0.95, epsilon: 1e-5)
}

@differentiable
Expand Down
4 changes: 2 additions & 2 deletions Transformer/Model.swift
Original file line number Diff line number Diff line change
Expand Up @@ -227,10 +227,10 @@ struct EncoderLayer: Layer {
size: size,
headCount: headCount)
selfAttentionDropout = Dropout(probability: dropProbability)
selfAttentionNorm = LayerNorm(featureCount: size, axis: 2, epsilon: Tensor<Float>(1e-5))
selfAttentionNorm = LayerNorm(featureCount: size, axis: 2, epsilon: 1e-5)
feedForward = FeedForward(size: size, hidden: 4 * size, dropProbability: dropProbability)
feedForwardDropout = Dropout(probability: dropProbability)
feedForwardNorm = LayerNorm(featureCount: size, axis: 2, epsilon: Tensor<Float>(1e-5))
feedForwardNorm = LayerNorm(featureCount: size, axis: 2, epsilon: 1e-5)
}

@differentiable(wrt: (self, input))
Expand Down
2 changes: 1 addition & 1 deletion Transformer/PythonCheckpointReader.swift
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ extension LayerNorm: InitializableFromPythonCheckpoint {
offset: readTensor(fromPath: path, name: scope + "/b", scalarType: Scalar.self),
scale: readTensor(fromPath: path, name: scope + "/g", scalarType: Scalar.self),
axis: -1,
epsilon: Tensor(1e-5))
epsilon: 1e-5)
}
}

Expand Down