Last active
November 2, 2020 09:33
-
-
Save jinglescode/c01185a583540cb9716d2ab9f8eff407 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class TestConv1d(nn.Module): | |
def __init__(self): | |
super(TestConv1d, self).__init__() | |
self.conv = nn.Conv1d(in_channels=2, out_channels=2, kernel_size=1, groups=2, bias=False) | |
self.init_weights() | |
def forward(self, x): | |
return self.conv(x) | |
def init_weights(self): | |
print(self.conv.weight.shape) | |
self.conv.weight[0,0,0] = 2. | |
self.conv.weight[1,0,0] = 4. | |
in_x = torch.tensor([[[1,2,3,4,5,6],[10,20,30,40,50,60]]]).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