Machine Learning Diary 001: Swift detour, and Recreating FastAI's Collaborative Filtering

I've been spending quite a bit of my free time studying machine learning over the past 3 months. After spending quite a bit of time deciding what learning materials to start with, I decided on's Practical Deep Learning for Coders (I saw the 2019 version). Overall I highly recommend the course, and I'm planning to go back and do the 2020 version of it.

One reason I was excited about's course is that they had some content on Swift for TensorFlow (S4TF). I have written a lot of Python and while it has its place, I was excited to try something new and hopefully better. I watched the two videos on S4TF and then decided to try it out. This ended up being a fairly costly mistake for me. Basically S4TF is just not nearly as mature as PyTorch, and I wasted a bunch of time struggling with environment setup (no equivalent to conda install), bugs, very incomplete documentation, and cryptic error messages. At this point (I tried in 2020-09), I suggest you steer clear of S4TF if your primary goal is just to learn ML. Though it was fun to learn some Swift and I'd definitely consider using Swift in future projects, ML or otherwise.

With that multi-week detour out of the way, I decided to focus on PyTorch. For my first task I decided to try to recreate the simplest model presented in the course, but without using the fastai library at all, just pure PyTorch. I found that almost all of the special stuff in fastai is included in PyTorch as of 1.6, so this was a lot easier than I expected. Here's my final notebook for this collaborative filtering task. Some of the issues I ran into and how I resolved them: