I want to implement a conditional computation graph in Pytorch. Since the exact computational graph differs from one data sample to another, I was wondering if batch processing is possible or not. My objective is to achieve the following
def forward(self, x):
if (self.x.data > 0):
return self.linear1(x)
else:
return self.linear2(x)
But the above doesn’t work. Am I missing something?