我正在嘗試我的__init__功能: self.downscale_time_conv = np.empty(8, dtype=object) for i in range(8): self.downscale_time_conv[i] = torch.nn.ModuleDict({})但在我的forward,我有: down_out = False for i in range(8): if not down_out: down_out = self.downscale_time_conv[i][side](inputs) else: down_out += self.downscale_time_conv[i][side](inputs)我得到:RuntimeError: Input type (torch.cuda.FloatTensor) and weight type (torch.FloatTensor) should be the samePython火炬張量
1 回答

蕭十郎
TA貢獻(xiàn)1815條經(jīng)驗(yàn) 獲得超13個(gè)贊
self.downscale_time_conv = torch.nn.ModuleList()
for i in range(8):
self.downscale_time_conv.append(torch.nn.ModuleDict({}))
這解決了它。顯然我需要使用ModuleList
添加回答
舉報(bào)
0/150
提交
取消