0
現在、PyTorchを使用してREINFORCEアルゴリズムを実装しようとしています。私は報酬を割り引いた後に責任ある成果を集めることができるようにしたい。したがって、アクションのメモリが与えられた場合、インデックスのテンソルを作成し、Tensor.index_selectを使用しようとしますが、成功しません。誰も助けることができますか?PyTorch Tensor.index_select()の使用方法は?
rH = np.array(rH) # discounted reward
aH = np.array(aH) # action_holder
sH = np.vstack(np.array(sH)) # states holder
statesTensor = Variable(torch.from_numpy(sH).type(torch.FloatTensor))
out = model.forward(statesTensor)
indexes = GuiltyOnes(out, aH)
flat = out.view(1,-1)
respos = torch.index_select(flat, 1, torch.from_numpy(indexes).type(torch.LongTensor))
私は次のエラーを取得する:
return IndexSelect.apply(self, dim, index)
RuntimeError: save_for_backward can only save input or output tensors, but argument 0 doesn't satisfy this condition