Hi,
I want to use multiple convolution filters in parallel with initial weights (I want the filter values to be fixed).
Below is an example of the desired code. Filter lengths are different but the output dimension will be the same due to the padding. In this example, I only used three filters but I would like to use more than a hundred filters. In this case,
- What is the best practice to initialize multiple (>100) convolution filters?
- And how can I concatenate them all?
(Let’s assume I already have the filter_weights array)
class Model(nn.Module):
def __init__():
super(Model, self).__init__()
self.filter_weights = [torch.tensor([[[0.1, 0.2, 0.3]]]),
torch.tensor([[[0.1, 0.2, 0.3, 0.4, 0.5]]]),
torch.tensor([[[0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7]]])]
def forward(x):
out1 = F.conv1d(x, self.filter_weights[0], padding=1)
out2 = F.conv1d(x, self.filter_weights[1], padding=2)
out3 = F.conv1d(x, self.filter_weights[2], padding=3)
out = torch.cat([out1, out2, out3], dim=1)
return out