Skip to content

Instantly share code, notes, and snippets.

@jinglescode
Created November 2, 2020 09:24
Show Gist options
  • Save jinglescode/69f52e95790b8e8db8c2124d0a961317 to your computer and use it in GitHub Desktop.
Save jinglescode/69f52e95790b8e8db8c2124d0a961317 to your computer and use it in GitHub Desktop.
class TestConv1d(nn.Module):
def __init__(self):
super(TestConv1d, self).__init__()
self.conv = nn.Conv1d(in_channels=1, out_channels=1, kernel_size=1, bias=False)
self.init_weights()
def forward(self, x):
return self.conv(x)
def init_weights(self):
self.conv.weight[0,0,0] = 2.
in_x = torch.tensor([[[1,2,3,4,5,6]]]).float()
print("in_x.shape", in_x.shape)
print(in_x)
net = TestConv1d()
out_y = net(in_x)
print("out_y.shape", out_y.shape)
print(out_y)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment