Why can you call model without specifying forward method

python question.

When you call model(...), you are actually calling model.__call__(...). As you can see here, the __call__ method on nn.Module eventually calls forward along with taking care of tracing and hooks.

5 Likes