AttributeError: module 'torch' has no attribute 'randn'

How do you name your file? I named it as torch.py and it tried to import this file. Of course it has nothing there. The solution could be: 1. install pytorch properly; 2. rename your python file other than torch.py.

Ref: MacOS conda install fails