Skip to content

Instantly share code, notes, and snippets.

@jinglescode
Created November 2, 2020 09:25
Show Gist options
  • Save jinglescode/6a6bf9450b7e9bd63fc939ae07d5417a to your computer and use it in GitHub Desktop.
Save jinglescode/6a6bf9450b7e9bd63fc939ae07d5417a 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=2, bias=False)
self.init_weights()
def forward(self, x):
return self.conv(x)
def init_weights(self):
self.conv.weight[0,0,0] = 2.
self.conv.weight[0,0,1] = 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