Convention for: import torch as

When reading through pytorch documentation/codes, one can quickly notice the habit of typing ‘torch’ in full many times instead of using a 2-letter abbreviation such as np for numpy or tf for tensorflow. Of course, you’re free to use whatever abbreviation you want or none at all, but I think it would be better if the pytorch community agreed on a standard convention that is used and seen across all codes/documents. Two possibilities come to mind are:

  • import torch as pt # pt for pytorch
  • import torch as tc # tc for torch, using the 1st and 4th letters from torch, similar to np for numpy

Any thoughts?

1 Like

Just “torch” is fine–it’s not like you’re typing “TensorFlow,” all PyTorch code I’ve ever seen uses it (tutorials included), and switching everyone would be an inordinately huge hassle just to save two characters here and there.


Why not be simpler? just

import torch as t

I like import torch as th, but few people do so.