我想创建一个模型,可以预测一个9x9井字游戏脚趾赢家基于球员的举动。 以下是我的数据集中的一个示例:
..................................x.............................................. 14 L
..............o...................x.................x............................ 67 L
..............o...............x...x.................x..............o............. 2 L
有81个字段可以是X
或o
。左边的数字是对手的下一步(对手总是0)。字母代表游戏的结果。我决定用0
替换所有"."
,用1替换x
,用2替换o
。L
或W
与一个热编码。我用future step压缩我的位置,并将其输入到模型中。那就是我遇到麻烦的地方。我的列车尺寸是(249561,80,1)。我的样车是
tensor([0, 0, 0, 0, 1, 2, 1, 2, 0, 0, 2, 0, 0, 0, 0, 2, 1, 0, 0, 0, 1, 2, 2, 2,
0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 2, 0, 2, 0, 1, 0, 0, 0, 2, 0, 1, 0, 1, 1,
1, 0, 2, 0, 0, 1, 2, 1, 0, 0, 1, 2, 2, 1, 1, 0, 0, 0, 0, 0, 2, 1, 0, 2,
0, 0, 1, 0, 0, 0, 2, 0], [67])
我试过了
self.fc = nn.Sequential(
nn.Linear(80, 4096),
nn.ReLU(),
nn.Dropout(p=0.5),
nn.Linear(4096, 2048),
nn.ReLU(),
nn.Dropout(p=0.5),
nn.Linear(2048, 1),
)
def forward(self, x):
logit = self.fc(x)
return logit
当我通过训练循环时,我得到一个错误RuntimeError: Expected object of scalar type Float but got scalar type Long for argument #2 'mat1' in call to _th_addmm
我有两个问题。我的数据处理是否正确?我应该使用什么模型?你知道吗
要解决RuntimeError(这是一个非常描述性的问题),您必须简单地将张量从Long转换为Float:
或者,在构建样本时,将替换从
[0, 1, 2]
(Long)更改为[0., 1., 2.]
(Float)。你知道吗相关问题 更多 >
编程相关推荐