Difference between writing in a single line


is there a difference between

x = F.leaky_relu(self.in_2(self.conv1(x)), inplace=True)


x = self.conv1(x)
x = self.in_2(x)
x = F.leaky_relu(x, inplace=True)

Does writing in a single line mean multiple feature maps won’t be created?
What are the pros and cons?

Both code snippets will create the same output.
It’s basically a question of your coding style.

In the second example, you could add some debugging print statement slightly easier, e.g. in case you would like to see the shape of the intermediate activation.

Thanks, I thought that the first one would use less memory as compared to the second one. It’s not the case, right?

That shouldn’t be the case, since x is reused and thus will be overwritten while Autograd will take care of creating the same computation graph.