0

我是 PyTorch 的新手,我正在尝试使用 IntelliJ PyCharm 调试我的代码。我有一行记录了 torch.IntTensor 的内容

logger.debug(f"action_tensor    = {action_tensor}")

大多数时候这似乎工作得很好,但偶尔打印输出会在张量中显示一个或几个巨大的值,例如:

2021-08-06 09:21:17,737 DEBUG main.py state_tensor = tensor([2089484293,          0,          0,          1,          0,          1,
                 1,          0,          0,          0,          0,          0,
                 0,          1,          1,          1,          1,          1,
                 1,          1,          1,          2,          2,          0,
                 0,          0,          0,          0,          0,          6,
                 0,          0,          0,          0,          0,          0,
                 0,          0,          0,          0,          0],
       dtype=torch.int32)

张量是通过从对象的状态中提取一些值来创建的

rolls = int(self.rolls)
allowed = [int(self.scorecard[c]["allowed"] == True) for c in self.scorecard]
scored = [int(self.scorecard[c]["score"]) if self.scorecard[c]["score"] else int(0) for c in self.scorecard]
return torch.cat([torch.IntTensor(rolls),
                  torch.IntTensor(allowed),
                  torch.IntTensor(scored)])

我已经检查了多次,这些值都不可能像上面的示例一样大(例如2089484293)。我试过只创建一个 numpy 数组而不是张量,并打印显示没有问题。我怀疑关于torch.IntTensor 有什么我不知道的。

我创建张量的方式有什么问题导致有时出现这些巨大的值?

4

0 回答 0