Is model.forward(x) the same as model.__call__(x)?

__call__ is already defined in nn.Module, will register all hooks and call your forward. That’s also the reason to call the module directly (output = model(data)) instead of model.forward(data).

11 Likes