Duplicate of What is the difference between torch.nn and torch.nn.functional? 12
Torch.nn defines Python classes (to be called in forward propagation), while torch.nn.fucntional defines operations which can be directly used.