Open
Description
The BasicGradientDescent example is crashing here with EXC_BAD_ACCESS on the first call to the loss function.
This is on an M1 MacBook with:
Xcode: 15.2
Toolchain: Swift Development Snapshot 2024-02-04 (a)
Project setup is via New Project with template MacOS Command Line Tool, then pasting your main.swift over the generated one.
(The other examples build and run correctly with this setup).
For some reason the crash can be fixed by unrolling the loop inside the loss function like this:
var data = andGateData[0]
var prediction = model(data.x1, data.x2)
var error = data.y - prediction
loss = loss + error * error / 2
data = andGateData[1]
prediction = model(data.x1, data.x2)
error = data.y - prediction
loss = loss + error * error / 2
data = andGateData[2]
prediction = model(data.x1, data.x2)
error = data.y - prediction
loss = loss + error * error / 2
data = andGateData[3]
prediction = model(data.x1, data.x2)
error = data.y - prediction
loss = loss + error * error / 2
Metadata
Metadata
Assignees
Labels
No labels