pytorch 中的张量除法。断言错误
tensor division in pytorch. Assertion error
这是一个 pytorch 初学者问题。在 pytorch 中,我试图用两个大小为 [5,5,3] 的张量进行元素明智的除法。在 numpy 中它使用 np.divide() 工作正常,但不知何故我在这里遇到错误。我正在为 Python 3.5.
使用 PyTorch 版本 0.1.12
c = [torch.DoubleTensor 大小 5x5x3]
input_patch = [torch.FloatTensor 尺寸 5x5x3]
input_patch 是 torch.autograd 变量的一部分,c 是通过执行 c = torch.from_numpy(self.patch_filt[:, :, :, 0] ).浮动()
做的时候:
torch.div(input_patch, c)
我收到这个我不明白的错误。
line 317, in div
assert not torch.is_tensor(other)
AssertionError
这是否意味着变量 c 不应该是 torch_tensor?在将 c 也转换为 FloatTensor 之后,仍然会出现相同的错误。
谢谢!
Input_patch 是 torch.autograd 变量的一部分,c 是通过
c = torch.from_numpy(self.patch_filt[:, :, :, 0]).float()
无论如何,mexmex,多亏了你的评论,我已经通过将 c 定义为
来解决它
Variable(torch.from_numpy(self.patch_filt[:, :, :, 0])).float()
这是一个 pytorch 初学者问题。在 pytorch 中,我试图用两个大小为 [5,5,3] 的张量进行元素明智的除法。在 numpy 中它使用 np.divide() 工作正常,但不知何故我在这里遇到错误。我正在为 Python 3.5.
使用 PyTorch 版本 0.1.12c = [torch.DoubleTensor 大小 5x5x3]
input_patch = [torch.FloatTensor 尺寸 5x5x3]
input_patch 是 torch.autograd 变量的一部分,c 是通过执行 c = torch.from_numpy(self.patch_filt[:, :, :, 0] ).浮动()
做的时候:
torch.div(input_patch, c)
我收到这个我不明白的错误。
line 317, in div
assert not torch.is_tensor(other)
AssertionError
这是否意味着变量 c 不应该是 torch_tensor?在将 c 也转换为 FloatTensor 之后,仍然会出现相同的错误。
谢谢!
Input_patch 是 torch.autograd 变量的一部分,c 是通过
c = torch.from_numpy(self.patch_filt[:, :, :, 0]).float()
无论如何,mexmex,多亏了你的评论,我已经通过将 c 定义为
来解决它Variable(torch.from_numpy(self.patch_filt[:, :, :, 0])).float()