Which import is better?

%%timeit -n 1000000
import torch.nn as nn
1000000 loops, best of 3: 357 ns per loop

%%timeit -n 1000000
import torch.nn
1000000 loops, best of 3: 307 ns per loop

%%timeit -n 1000000
from torch import nn
1000000 loops, best of 3: 864 ns per loop

I’ve never seen someone profiling the import. :slight_smile:

My personal and biased choice is import torch.nn as nn.