今天碰上了需要使用Conv1d的场景,但是对于in_channel,out_channel和kernel_size所影响的Conv1d层而进行的操作还是十分的迷惑,因此写下此篇文章记录自己的学习过程。...[formula](/assets/20210927 conv1d/Conv1d_formula.png)
从公式可以看出,输入到Conv1d中的数据有三个维度,第一个维度N一般是batch_size,...[0,0], test_layer.weight[0,1],test_layer.weight[0,2])
# tensor([-0.1468, -0.0057, 0.0926, 0.0263],...,即为所有的in_channel与weight上对应的kernel_size做卷积的结果
a1 = torch.sum(test_layer.weight[0,0]*test_data[0,0,0:4]...[0,2])
print(test_layer.weight[1,0], test_layer.weight[1,1],test_layer.weight[1,2])
a1 = torch.sum(test_layer.weight