Julian's musings

The PyTorch add_module() function

deep-learningPermalink

I have been building some bespoke PyTorch models, and have just been stung by a bug; it turns out that using the add_module() method is sometimes critical to making a PyTorch model work. Without this method, the program may just crash, but might also just about work but give completely meaningless results.

Though there do not seem to be any hints about this in the documentation, it seems that PyTorch determines the layers or others Modules used in a particular Module by looking at the type of object stored in each member of the Module. And if that object is not a Module, PyTorch does not recognise it and will not backpropagate through it.

Installing PyTorch on Debian bullseye (Debian 11)

deep-learningPermalink

I have just rebuilt PyTorch for my Debian bullseye machine (Debian 11 as it will become) from source. This blog post documents how I did this.

Installing TensorFlow and TensorFlow Addons on Debian bullseye (Debian 11)

deep-learningPermalink

Though I usually use PyTorch for my deep learning work, I have just been given a piece of code written using TensorFlow, so I needed to install TensorFlow and TensorFlow Addons on my Debian testing system (aka Debian bullseye, which will shortly become Debian 11). Unfortunately, the binaries available on PyPI are only built for Python 3.6-3.8, but Debian bullseye now runs Python 3.9.

This blog post documents how I managed to build these packages for my system (which was far more effort than it probably should have been!).