Hi guys,
Total noob here.
So, I have the following code
class MyModel(nn.Module):
def __init__(self, depth, some var, some var1):
super(MyModel self).__init__()
def L1_block(self, x, before_trans = True):
some code
def L2_block(self, x, before_trans = True):
some code
def U1_block(self, x, before_trans = True):
some code
def U2_block(self, x, before_trans = True):
some code
def forward(self, x, concat_only=True):
output_var = ['l1_out', 'l2_out', 'u1_out', 'u2_out']
output_var_t = ['l1_out_t', 'l2_out_t', 'u1_out_t', 'u2_out_t']
l1_out = self.L1_block(x, before_trans=True)
l1_out_t = self.L1_block(x, before_trans=False)
l2_out = self.L2_block(l1_out_t, before_trans=True)
l2_out_t = self.L2_block(l1_out_t, before_trans=False)
u1_out = self.U1_block(l2_out_t, l1_out, l2_out, x, before_trans=True)
u1_out_t = self.U1_block(l2_out_t, l1_out, l2_out, x, before_trans=False)
u2_out = self.U2_block(u1_out_t, l1_out, l2_out, u1_out, x, before_trans=True)
u2_out_t = self.U2_block(u1_out_t, l1_out, l2_out, u1_out, x, before_trans=False)
if concat_only:
return dict(zip(output_var, (l1_out, l2_out, u1_out, u2_out)))
else:
return dict(zip(output_var_t, (l1_out_t, l2_out_t, u1_out_t, u2_out_t)))
My question is, in the forward pass, will the x be the same all through, or will it change at each line of code? x is the input data (Iād assume). I want the x, in this case, to be the same all through the forward, hence the reason for calling it at each block of code.
Thanks so much for the help.