小编Ram*_*mzy的帖子

运行时错误:找到 dtype Double 但预期为 Float - PyTorch

我是 pytorch 的新手,我正在使用强化学习对时间序列进行 DQN 工作,我需要对时间序列和一些传感器读数进行复杂的观察,所以我合并了两个神经网络,我不确定这是否会破坏我的损失.向后或其他什么。我知道有多个具有相同标题的问题,但没有一个对我有用,也许我错过了一些东西。
首先,这是我的网络:

class DQN(nn.Module):
  def __init__(self, list_shape, score_shape, n_actions):
    super(DQN, self).__init__()

    self.FeatureList =  nn.Sequential(
            nn.Conv1d(list_shape[1], 32, kernel_size=8, stride=4),
            nn.ReLU(),
            nn.Conv1d(32, 64, kernel_size=4, stride=2),
            nn.ReLU(),
            nn.Conv1d(64, 64, kernel_size=3, stride=1),
            nn.ReLU(),
            nn.Flatten()
        )
    
    self.FeatureScore = nn.Sequential(
            nn.Linear(score_shape[1], 512),
            nn.ReLU(),
            nn.Linear(512, 128)
        )
    
    t_list_test = torch.zeros(list_shape)
    t_score_test = torch.zeros(score_shape)
    merge_shape = self.FeatureList(t_list_test).shape[1] + self.FeatureScore(t_score_test).shape[1]
    
    self.FinalNN =  nn.Sequential(
            nn.Linear(merge_shape, 512),
            nn.ReLU(),
            nn.Linear(512, 128),
            nn.ReLU(),
            nn.Linear(128, n_actions),
    )
    
  def forward(self, list, score):
    listOut = self.FeatureList(list)
    scoreOut = self.FeatureScore(score)
    MergedTensor = torch.cat((listOut,scoreOut),1) …
Run Code Online (Sandbox Code Playgroud)

python reinforcement-learning python-3.x pytorch

1
推荐指数
1
解决办法
4027
查看次数