user18081522
user18081522

Reputation:

What does self.model(batch) do in pytorch?

I am currently rewriting a PyTorch code to tensorflow. During this I found a line that I don't understand, so I am not able to translate it to tensorflow.

Can someone explain me what this does/ means?

self.model(batch)

Upvotes: 1

Views: 699

Answers (1)

Shai
Shai

Reputation: 114866

It seems like self.model is a layer/layers of a neural network, derived from nn.Module class.
The call self.model(batch) invoke's self.model's __call__ method with the argument batch.
If you inspect closely, nn.Module.__call__ do some "bookkeeping" but essentially, it calls the self.model's forward function.

Upvotes: 5

Related Questions