ConV-1d遇到的数据维度问题
在这里我将ConV-1d都换成了ConV-2d,目前代码是可以运行的。我使用的pytorch是2.0.1。后来发现是Conv-1d和Conv-2d的问题,其实在这个代码包底下也有很多人提出了疑问。仔细检查了数据的维度,后来又使用了github上原数据集, 但是还是在报错。将pytorch版本换为老版本进行计算。
swap.py maybe unsupport torch-1.11.0 · Issue #161 · YuvalNirkin/fsgan · GitHub
首先贴出解决方案:
在做spatio-temporal问题的时候,在数据维度上遇到问题:
RuntimeError: Expected 2D (unbatched) or 3D (batched) input to conv1d, but got input of size: [64, 32, 207, 13]
仔细检查了数据的维度,后来又使用了github上原数据集, 但是还是在报错。
后来发现是Conv-1d和Conv-2d的问题,其实在这个代码包底下也有很多人提出了疑问。
gated TCN中一个用的是Conv-2d,一个用的是Conv-1d,是出于什么考虑呢 · Issue #18 · nnzhan/Graph-WaveNet · GitHub
解决方法1:
在这里我将ConV-1d都换成了ConV-2d,目前代码是可以运行的。 我使用的pytorch是2.0.1
贴出网友的回答是:
nn.Conv1d
expects a 3-dimensional input in the shape [batch_size, channels, seq_len]
while you are using a 4-dimensional input.
If your input represents [batch_size, channels, height, width]
use nn.Conv2d
or manipulate the shape to create a 3-dimensional tensor (e.g. by flattening the spatial dimensions into a single one, if this fits your use case).
解决方法2:
将pytorch版本换为老版本进行计算
pytorch=1.10
更多推荐
所有评论(0)