EDGE FDE
IntermediatePyTorch to Core AI in Xcode (Fashion-MNIST)
On a Mac, train a small clothing model on Fashion-MNIST. Use MPS if you have it, or CPU if you do not. Convert it to .aimodel, then show the top label in a SwiftUI app with Core AI.
This course is for you if you can write Python and Swift, and you are new to Core AI.
Lessons
Key concepts
- Train
ClothingCNNon Fashion-MNIST on a Mac with MPS or CPU. Never CUDA. - Save
clothing.pt, export, then convert withcoreai-torchtoclothing.aimodel. - Fixed contract: input
imageis NCHW[1, 1, 28, 28]float32. Outputlogitsis[1, 10]float32. - Xcode 27 loads function
main. Prepare once. Softmax is for display only.
Takeaways
- You can train, convert, and show a clothing label in a SwiftUI Core AI app.
- You can profile load, specialisation, and inference on a real device.
- You can check held-out accuracy, Mac versus Core AI labels, and a yes or no top-label rule.
Agent briefs
FAQ
Can I train on a Mac then run in an iOS app?
Yes. Train in PyTorch on MPS/CPU, convert with coreai-torch to a .aimodel, then load in Xcode on iOS/macOS 27+.
What is coreai-torch?
Apple's converter that turns a trained PyTorch model into a Core AI .aimodel for on-device inference.
Is Fashion-MNIST production-ready?
No — it is the teaching classifier used to prove the train→convert→ship loop before you swap in your own data.
Do I need MLX for this path?
No. This course uses PyTorch + coreai-torch. MLX is a separate train/experiment stack (see Core AI vs Core ML vs MLX).
Where does LiteRT fit?
LiteRT is the Android sibling path — see PyTorch to Android with LiteRT.
Related courses
PyTorch to Android with LiteRT · From the metal to the model · Model architectures in plain English · Diffusion LoRA to Core AI on device · MLX Swift in production · Core AI Fast First Token and the Right Compute Unit