简体   繁体   English

PyTorch Conv1d 参数

[英]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:我需要分类的每个数据单元都由 65 个不同的时间序列组成,每个序列包含 50 个时间样本,所以如果我写:

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

I will get: [56,50] .我会得到: [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:问题是我无法正确输入第一个nn.Conv1d层 - 现在我正在使用:

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).但是当我运行批量大小为 100 的 model 时,输入变为[100,56,50]的形状,并且我只得到一个批量大小为 100(而不是 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])

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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