[英]How to fix error with pytorch conv2d function?
我正在嘗試在這兩個張量上使用 conv2d function :
Z = np.random.choice([0,1],size=(100,100))
Z = torch.from_numpy(Z).type(torch.FloatTensor)
print(Z)
tensor([[0., 0., 1., ..., 1., 0., 0.],
[1., 0., 1., ..., 1., 1., 1.],
[0., 0., 0., ..., 0., 1., 1.],
...,
[1., 0., 1., ..., 1., 1., 1.],
[1., 0., 1., ..., 0., 0., 0.],
[0., 1., 1., ..., 1., 0., 0.]
和
filters = torch.tensor(np.array([[1,1,1],
[1,0,1],
[1,1,1]]), dtype=torch.float32)
print(filters)
tensor([[1., 1., 1.],
[1., 0., 1.],
[1., 1., 1.]])
但是當我嘗試做torch.nn.functional.conv2d(Z,filters)
這個錯誤返回:
RuntimeError: weight should have at least three dimensions
我真的不明白這里有什么問題。 如何解決?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.