junxiaosong / AlphaZero_Gomoku

An implementation of the AlphaZero algorithm for Gomoku (also called Gobang or Five in a Row)
MIT License
3.28k stars 965 forks source link

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

Open ToBeIronMan opened 4 years ago

ToBeIronMan commented 4 years ago

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

syys96 commented 4 years ago

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

yaohaizhou commented 4 years ago

应该在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 commented 4 years ago

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