I am trying to make a model for pixel rendering.
this is how the model looks like.
class RGB_to_PenTile_to_RGB(nn.Module):
def init(self):
super().init()
    self.conv1 = nn.Conv2d(3, 64, kernel_size=7, padding=2, padding_mode='replicate')
    self.conv2 = nn.Conv2d(64, 64, kernel_size=1, padding=2, stride=2, padding_mode='replicate')
    self.conv3 = nn.Conv2d(64, 32, kernel_size=1, padding=0, stride=1)
    self.conv4 = nn.Conv2d(32, 32, kernel_size=1, padding=0, stride=1)
    self.conv5 = nn.Conv2d(32, 1, kernel_size=6, padding=2, padding_mode='replicate')
    self.conv6 = nn.Conv2d(32, 1, kernel_size=6, padding=2, stride=2, padding_mode='replicate')
    self.conv7 = nn.Conv2d(32, 1, kernel_size=6, padding=2, stride=2, padding_mode='replicate')
    self.conv8 = nn.Conv2d(32, 1, kernel_size=6, padding=2, stride=2, padding_mode='replicate')
    self.conv9 = nn.Conv2d(32, 1, kernel_size=6, padding=2, stride=2, padding_mode='replicate')
    
def forward(self, x):
    x = F.relu(self.conv1(x))
    x = F.relu(self.conv2(x))
    x = F.relu(self.conv3(x))
    x = F.relu(self.conv4(x))
    
    g = self.conv5(x)
    r1 = self.conv6(x)
    r2 = self.conv7(x)
    b1 = self.conv8(x)
    b2 = self.conv9(x) 
    
    r1 = F.conv_transpose2d(r1, mask_R1, stride=4, padding=0) *This is where the error occurs.*
    r2 = F.conv_transpose2d(r2, mask_R2, stride=4, padding=0)
    g = F.conv_transpose2d(g, mask_G, stride=2, padding=0)
    b1 = F.conv_transpose2d(b1, mask_B1, stride=4, padding=0)
    b2 = F.conv_transpose2d(b2, mask_B2, stride=4, padding=0)

    r, b = torch.add(r1,r2), torch.add(b1,b2)

    print('b',b)
    r = F.conv2d(r, weights_RB, None, 1, 3)
    g = F.conv2d(g, weights_G, None, 1, 1)
    b = F.conv2d(b, weights_RB, None, 1, 3)

    outputs = torch.cat((r,g,b), dim=1)
 
    return outputs

and the filter looks like.
mask_R1 = torch.tensor([
[0, 0, 0, 0],
[0, 1, 0, 0],
[0, 0, 0, 0],
[0, 0, 0, 0],
])
mask_R1 = mask_R1.view(1,1,4,4).float()
but it keeps showing this error.
RuntimeError: Input type (torch.cuda.FloatTensor) and weight type (torch.FloatTensor) should be the same
So my question is…
For training, how can I use a fixed weight convolution layer inside or outside the model?