Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/292.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 使用moduledit,我有:输入类型(torch.cuda.FloatTensor)和权重类型(torch.FloatTensor)应该相同_Python_Pytorch_Tensor - Fatal编程技术网

Python 使用moduledit,我有:输入类型(torch.cuda.FloatTensor)和权重类型(torch.FloatTensor)应该相同

Python 使用moduledit,我有:输入类型(torch.cuda.FloatTensor)和权重类型(torch.FloatTensor)应该相同,python,pytorch,tensor,Python,Pytorch,Tensor,我正在尝试我的\uuuu init\uuu函数: self.downscale_time_conv = np.empty(8, dtype=object) for i in range(8): self.downscale_time_conv[i] = torch.nn.ModuleDict({}) 但在我的转发中,我有: down_out = False for i in range(8):

我正在尝试我的
\uuuu init\uuu
函数:


        self.downscale_time_conv = np.empty(8, dtype=object)
        for i in range(8):
            self.downscale_time_conv[i] = torch.nn.ModuleDict({})
但在我的转发中,我有:

        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 same

这就解决了问题。显然我需要使用一个
模块列表

,这能回答你的问题吗?
        self.downscale_time_conv = torch.nn.ModuleList()
        for i in range(8):
            self.downscale_time_conv.append(torch.nn.ModuleDict({}))