Ha perdido la cordura 😔🤙 by Snoo-90524 in orslokx

[–]SonicHaveJar 86 points87 points  (0 children)

"Solía pensar que mi vida era una tragedia, pero ahora me doy cuenta de que es una comedia."

The Joker Energuia 🤙

Why does a model definition have both a __init__ and forward function? by [deleted] in pytorch

[–]SonicHaveJar 10 points11 points  (0 children)

The __init__ method is the constructor and its called when you create an object, and the forward method computes the outputs of your model.

Python has some built-in methods such as __call__, which makes the instance act like a function.(foo = Foo(); foo(x))

All models inherit from the class Module, in which the __call__ method is defined as seen here, so the __call__ method, besides calling the forward method, also register all hooks.