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

Commit 2d1f616

Browse files
authored
Use updated APIs ( and toAccelerator). (#17)
- `Tensor.dot(_:)` and `⊗` were deprecated in favor of `matmul(_:_:)` and `•`. - `toDevice` was renamed to `toAccelerator`.
1 parent be86ede commit 2d1f616

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

MNIST/MNIST.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,17 +75,17 @@ func main() {
7575
var i: Int32 = 0
7676
repeat {
7777
// Forward pass.
78-
let z1 = images w1 + b1
78+
let z1 = images w1 + b1
7979
let h1 = sigmoid(z1)
80-
let z2 = h1 w2 + b2
80+
let z2 = h1 w2 + b2
8181
let predictions = sigmoid(z2)
8282

8383
// Backward pass.
8484
let dz2 = (predictions - labels) / batchSize
85-
let dw2 = h1.transposed(withPermutations: 1, 0) dz2
85+
let dw2 = h1.transposed(withPermutations: 1, 0) dz2
8686
let db2 = dz2.sum(squeezingAxes: 0)
87-
let dz1 = dz2.dot(w2.transposed(withPermutations: 1, 0)) * h1 * (1 - h1)
88-
let dw1 = images.transposed(withPermutations: 1, 0) dz1
87+
let dz1 = matmul(dz2, w2.transposed(withPermutations: 1, 0)) * h1 * (1 - h1)
88+
let dw1 = images.transposed(withPermutations: 1, 0) dz1
8989
let db1 = dz1.sum(squeezingAxes: 0)
9090

9191
// Gradient descent.

0 commit comments

Comments
 (0)