AlphaZero_Gomoku icon indicating copy to clipboard operation
AlphaZero_Gomoku copied to clipboard

大佬,你好,我在用pytorch训练出来的模型,无法加载运行,报了如下错误

Open ToBeIronMan opened this issue 4 years ago • 3 comments

Traceback (most recent call last): File "human_play.py", line 88, in run() File "human_play.py", line 81, in run game.start_play(human, mcts_player, start_player=0, is_shown=1) File "C:\Users\lucky\Desktop\AlphaZero_Gomoku-master\AlphaZero_Gomoku-master\game.py", line 177, in start_play move = player_in_turn.get_action(self.board) File "C:\Users\lucky\Desktop\AlphaZero_Gomoku-master\AlphaZero_Gomoku-master\mcts_alphaZero.py", line 190, in get_action acts, probs = self.mcts.get_move_probs(board, temp) File "C:\Users\lucky\Desktop\AlphaZero_Gomoku-master\AlphaZero_Gomoku-master\mcts_alphaZero.py", line 147, in get_move_probs self._playout(state_copy) File "C:\Users\lucky\Desktop\AlphaZero_Gomoku-master\AlphaZero_Gomoku-master\mcts_alphaZero.py", line 122, in _playout action_probs, leaf_value = self._policy(state) File "C:\Users\lucky\Desktop\AlphaZero_Gomoku-master\AlphaZero_Gomoku-master\policy_value_net_numpy.py", line 104, in policy_value_fn X = relu(conv_forward(X, self.params[i], self.params[i+1])) TypeError: 'int' object is not subscriptable

ToBeIronMan avatar Feb 28 '20 17:02 ToBeIronMan

pytorch训练的模型直接用pytoch加载不更好吗

syys96 avatar Apr 17 '20 15:04 syys96

应该在human_play.py中把 best_policy = PolicyValueNetNumpy(width, height, policy_param)改为 best_policy = PolicyValueNet(width, height, policy_param) 同时最上面解除 from policy_value_net_pytorch import PolicyValueNet # Pytorch 的注释

yaohaizhou avatar Jul 03 '20 05:07 yaohaizhou

还要把human_play.py中的 best_policy = PolicyValueNet(width, height, policy_param) 改为 best_policy = PolicyValueNet(width, height, model_file) 也就是说不需要使用pickle

yaohaizhou avatar Jul 04 '20 02:07 yaohaizhou