我收到一条错误消息:
Exception has occurred: ValueError
too many values to unpack (expected 2)
File "D:\Game Developlment\AI\Learning\Pong ai NEAT\mainTutorial.py", line 13, in <module>
model.learn(total_timesteps=20000)
我正在尝试学习 (本教程),这是关于 python 中的强化学习。我在 59:17 观看视频(如果重要的话),我真的希望能够训练我自己的 AI。有谁知道修复?我在终端中没有收到任何错误,但它什么也没做
代码:
import os
import gym
from stable_baselines3 import PPO
from stable_baselines3.common.vec_env import DummyVecEnv
from stable_baselines3.common.evaluation import evaluate_policy
Environment_name = 'CartPole-v0'
log_path = os.path.join('Training', 'Logs')# Make your directories first
env = gym.make(Environment_name)
env = DummyVecEnv([lambda: env])
model = PPO('MlpPolicy', env, verbose=1, tensorboard_log=log_path)
model.learn(total_timesteps=20000)
我13岁
我正在使用 vs 代码
# To avoid ValueError when unpakcing too many values apart from observations
class CustomDummyVecEnv(DummyVecEnv):
def reset(self):
for env_idx in range(self.num_envs):
obs, *_ = self.envs[env_idx].reset()
self._save_obs(env_idx, obs)
return self._obs_from_buf()
def step_wait(self):
for env_idx in range(self.num_envs):
obs, rew, done, info = self.envs[env_idx].step(self.actions[env_idx])
self.buf_rews[env_idx] = rew
self.buf_dones[env_idx] = done
self.buf_infos[env_idx] = info
if done:
obs, *_ = self.envs[env_idx].reset()
self._save_obs(env_idx, obs)
return (self._obs_from_buf(), self.buf_rews, self.buf_dones, self.buf_infos)
env = gym.make(environment_name)
env = CustomDummyVecEnv([lambda: env])
obs = env.reset()
model = PPO('MlpPolicy', env, verbose=1)
total_timesteps=20000
model.learn(total_timesteps)