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

Commit 36fdbb1

Browse files
authored
Removal of deprecated allDifferentiableVariables. (#194)
1 parent e319a07 commit 36fdbb1

File tree

7 files changed

+8
-8
lines changed

7 files changed

+8
-8
lines changed

Autoencoder/main.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,6 @@ for epoch in 1...epochCount {
9393
return meanSquaredError(predicted: image, expected: x)
9494
}
9595

96-
optimizer.update(&autoencoder.allDifferentiableVariables, along: 𝛁model)
96+
optimizer.update(&autoencoder, along: 𝛁model)
9797
}
9898
}

Catch/main.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ extension CatchAgent {
8585

8686
let 𝛁loss = -log(Tensor<Float>(ŷ.max())).broadcasted(like: ŷ) * previousReward
8787
let (𝛁model, _) = backprop(𝛁loss)
88-
optimizer.update(&model.allDifferentiableVariables, along: 𝛁model)
88+
optimizer.update(&model, along: 𝛁model)
8989

9090
return CatchAction(rawValue: Int(maxIndex))!
9191
}

Examples/Custom-CIFAR10/main.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ for epoch in 1...100 {
3939
}
4040
trainingLossSum += loss.scalarized()
4141
trainingBatchCount += 1
42-
optimizer.update(&model.allDifferentiableVariables, along: gradients)
42+
optimizer.update(&model, along: gradients)
4343
}
4444

4545
var testLossSum: Float = 0

Examples/LeNet-MNIST/main.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ for epoch in 1...epochCount {
5252
return loss
5353
}
5454
// Update the model's differentiable variables along the gradient vector.
55-
optimizer.update(&classifier.allDifferentiableVariables, along: 𝛁model)
55+
optimizer.update(&classifier, along: 𝛁model)
5656
}
5757

5858
Context.local.learningPhase = .inference

Examples/ResNet-CIFAR10/main.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ for epoch in 1...10 {
4444
}
4545
trainingLossSum += loss.scalarized()
4646
trainingBatchCount += 1
47-
optimizer.update(&model.allDifferentiableVariables, along: gradients)
47+
optimizer.update(&model, along: gradients)
4848
}
4949
var testLossSum: Float = 0
5050
var testBatchCount = 0

GAN/main.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ for epoch in 1...epochCount {
154154
let loss = generatorLoss(fakeLogits: fakeLogits)
155155
return loss
156156
}
157-
optG.update(&generator.allDifferentiableVariables, along: 𝛁generator)
157+
optG.update(&generator, along: 𝛁generator)
158158

159159
// Update discriminator.
160160
let realImages = dataset.trainingImages.minibatch(at: i, batchSize: batchSize)
@@ -167,7 +167,7 @@ for epoch in 1...epochCount {
167167
let loss = discriminatorLoss(realLogits: realLogits, fakeLogits: fakeLogits)
168168
return loss
169169
}
170-
optD.update(&discriminator.allDifferentiableVariables, along: 𝛁discriminator)
170+
optD.update(&discriminator, along: 𝛁discriminator)
171171
}
172172

173173
// Start inference phase.

Gym/CartPole/main.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ while true {
184184
return loss
185185
}
186186
}
187-
optimizer.update(&net.allDifferentiableVariables, along: gradients)
187+
optimizer.update(&net, along: gradients)
188188

189189
print("It has episode count \(episodeCount) and mean reward \(meanReward)")
190190

0 commit comments

Comments
 (0)