简体   繁体   中英

PyTorch Conv1d parameters

I am trying to use 1D convolution in order to classify a set of time signals. Every data unit I need to classify is made out of 65 different time series, each one contains 50 time samples, so if I write:

dataset = MyDataset(train,y_train_one_hot)
a,b = dataset[1]
print(a.shape)

I will get: [56,50] .

I want to run 1D convolutional filters on each one of the channels. Problem is I cant get right the inputs of the first nn.Conv1d layer - right now I am using:

self.c1 = nn.Conv1d(in_channels=56, out_channels=100, kernel_size=ks1)

but when I run the model with a batch size of 100, the input becomes of the shape [100,56,50] and I get only one prediction for a batch size of 100 (instead of 100X3). Can anyone help with the right syntax? Thank you very much!

This works for me

>>> conv = nn.Conv1d(in_channels=56 , out_channels=100, kernel_size=3)
>>> input = torch.randn(100, 56, 50)
>>> output = conv(input)
>>> output.shape
torch.Size([100, 100, 48])

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM