MCPcopy Create free account
hub / github.com/ml-explore/mlx-examples / train_step

Function train_step

speechcommands/main.py:60–64  ·  view source on GitHub ↗
(model, x, y)

Source from the content-addressed store, hash-verified

58
59def train_epoch(model, train_iter, optimizer, epoch):
60 def train_step(model, x, y):
61 output = model(x)
62 loss = mx.mean(nn.losses.cross_entropy(output, y))
63 acc = mx.mean(mx.argmax(output, axis=1) == y)
64 return loss, acc
65
66 state = [model.state, optimizer.state]
67

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected