beyretb / AnimalAI-Olympics

Code repository for the Animal AI Olympics competition
Apache License 2.0
574 stars 84 forks source link

Error when running trainMLAgents.py #32

Closed bastiankayser closed 5 years ago

bastiankayser commented 5 years ago

The following exception occurs when I run trainMLAgents.py with the provided configuration:

(venv) D:\Repos\AnimalAI-Olympics\examples>python trainMLAgents.py trainMLAgents.py:35: YAMLLoadWarning: calling yaml.load() without Loader=... is deprecated, as the default Loader is unsafe. Please read https://msg.pyyaml.org/load for full details. trainer_config = yaml.load(data_file) INFO:mlagents.envs: 'Academy' started successfully! Unity Academy name: Academy Number of Brains: 1 Number of Training Brains : 1 2019-07-02 22:04:20.888000: I tensorflow/core/platform/cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 INFO:mlagents.envs:Hyperparameters for the PPO Trainer of brain Learner: batch_size: 64 beta: 0.01 buffer_size: 2024 epsilon: 0.2 gamma: 0.99 hidden_units: 256 lambd: 0.95 learning_rate: 0.0003 max_steps: 5.0e6 normalize: False num_epoch: 3 num_layers: 1 time_horizon: 128 sequence_length: 64 summary_freq: 1000 use_recurrent: False summary_path: ./summaries/train_example-1_Learner memory_size: 256 use_curiosity: True curiosity_strength: 0.01 curiosity_enc_size: 256 model_path: ./models/train_example/Learner INFO:mlagents.trainers: train_example-1: Learner: Step: 1000. Mean Reward: -1.001. Std of Reward: 0.000. Training. INFO:mlagents.trainers: train_example-1: Learner: Step: 2000. No episode was completed since last summary. Training. Traceback (most recent call last): File "trainMLAgents.py", line 86, in tc.start_learning(env, trainer_config) File "D:\Repos\AnimalAI-Olympics\venv\lib\site-packages\animalai_train\trainers\trainer_controller.py", line 217, in start_learning new_info = self.take_step(env, curr_info) File "D:\Repos\AnimalAI-Olympics\venv\lib\site-packages\animalai_train\trainers\trainer_controller.py", line 288, in take_step trainer.update_policy() File "D:\Repos\AnimalAI-Olympics\venv\lib\site-packages\animalai_train\trainers\ppo\trainer.py", line 343, in update_policy run_out = self.policy.update(buffer.make_mini_batch(start, end), n_sequences) File "D:\Repos\AnimalAI-Olympics\venv\lib\site-packages\animalai_train\trainers\buffer.py", line 197, in make_mini_batch mini_batch[key] = np.array(self[key][start:end]) ValueError: could not broadcast input array from shape (129) into shape (1)

beyretb commented 5 years ago

Hi,

Unfortunately, there seems to be incompatibilities specific to Windows, which do not occur on linux or mac.

trainMLAgents.py worked on windows before we integrated Dopamine which requires tensorflow>=1.12. If you want to run the PPO example on windows you can try the old setup.py file for animalai-train which makes trainMLAgents.py work again but therefore prevents trainDopamine.py from working. Installing animalai-train using the following requirements seems to fix the issue:

install_requires=[
        'animalai>=1.0.2',
        'dopamine-rl',
        "tensorflow>=1.7,<1.8",
        'matplotlib',
        'Pillow',
        "numpy>=1.13.3,<=1.14.5",
        "protobuf>=3.6,<3.7",
        "grpcio>=1.11.0,<1.12.0",
        'pyyaml',
        'atari-py',
        'jsonpickle',
        'pypiwin32;platform_system=="Windows"']

Unfortunately we do not have the resources to fully support animalai-train on Windows at the moment (which is not required to compete and is provided as a starter pack only). The animalai package should work fine on Windows.