So I have this confusion for months now, should I use clone in the folliwng code for x
?
I am not sure if it is important or not, but I appreciate if someone can help me understand it.
Is it gonna effect the learning if I go with any of the following samples
Lets say I have a model that somewhere in it I have to use branches of an input and compute different output. I am wondering if I need to use clone or not.
Which one of the following models is correct?
class Model(nn.Module):
def __init__(self,):
super(Model, self).__init__()
self.conv = nn.Conv2d(3,6,3)
self.conv_2 = nn.Conv2d(6,2,3)
self.conv_3= nn.Conv2d(6,20,3)
def forward(self,input):
x = self.conv(input)
x_2 = self.conv_2(x)
x_3 = self.conv_3(x)
return x_2,x_3
class Model(nn.Module):
def __init__(self,):
super(Model, self).__init__()
self.conv = nn.Conv2d(3,6,3)
self.conv_2 = nn.Conv2d(6,2,3)
self.conv_3= nn.Conv2d(6,20,3)
def forward(self,input):
x = self.conv(input)
x_2 = self.conv_2(x.clone())
x_3 = self.conv_3(x)
return x_2,x_3
class Model(nn.Module):
def __init__(self,):
super(Model, self).__init__()
self.conv = nn.Conv2d(3,6,3)
self.conv_2 = nn.Conv2d(6,2,3)
self.conv_3= nn.Conv2d(6,20,3)
def forward(self,input):
x = self.conv(input)
x_2 = self.conv_2(x.clone())
x_3 = self.conv_3(x.clone())
return x_2,x_3