Search Unity

Error when I learn with a demo

Discussion in 'ML-Agents' started by LexVolkov, Mar 25, 2020.

  1. LexVolkov

    LexVolkov

    Joined:
    Sep 14, 2014
    Posts:
    62
    Hello/ I get an error when I try to teach my bot using demontration. What does that mean?

    ValueError: Cannot feed value of shape (128, 4) for Tensor 'Placeholder_2:0', which has shape '(?, 3)'
     
  2. christophergoy

    christophergoy

    Unity Technologies

    Joined:
    Sep 16, 2015
    Posts:
    735
    Hi @crazywolfcub,
    Could you provide more information about what you are doing?
    How did you record your demo?
    How are you feeding your demo to your agent?
    What is your observation and action space?
    Thanks,
    Chris
     
  3. LexVolkov

    LexVolkov

    Joined:
    Sep 14, 2014
    Posts:
    62
    I recorded the demonstration through the component DemonstrationRecorder
    Agent have 5 observation and 3 stacked vector
    Discrete Branche 3 [3,3,3]
    The demo file is in the project folder.
    in yaml rwite like pyramids ex.:
    extrinsic:
    strength: 2.0
    gamma: 0.99
    gail:
    strength: 0.02
    gamma: 0.99
    encoding_size: 128
    use_actions: true
    demo_path: W:/UnityProjects/FamProject_AI/Assets/World/Demos/FamSurvDemo.demo
     
  4. LexVolkov

    LexVolkov

    Joined:
    Sep 14, 2014
    Posts:
    62
    And 2 Per. Ray
     
  5. christophergoy

    christophergoy

    Unity Technologies

    Joined:
    Sep 16, 2015
    Posts:
    735
    Sorry, I don't understand what this means.
     
  6. christophergoy

    christophergoy

    Unity Technologies

    Joined:
    Sep 16, 2015
    Posts:
    735
    Are you recording demos for the Pyramid scene and trying to train with those?
     
  7. LexVolkov

    LexVolkov

    Joined:
    Sep 14, 2014
    Posts:
    62
    Agent have two 3D Ray Perception Sensors
     
  8. LexVolkov

    LexVolkov

    Joined:
    Sep 14, 2014
    Posts:
    62
    No, I recorded a new
     
  9. christophergoy

    christophergoy

    Unity Technologies

    Joined:
    Sep 16, 2015
    Posts:
    735
    Can you send a screenshot of what your demo file looks like in the inspector window? Like you see here.
     
  10. LexVolkov

    LexVolkov

    Joined:
    Sep 14, 2014
    Posts:
    62
    Version information:
    ml-agents: 0.15.0,
    ml-agents-envs: 0.15.0,
    Communicator API: 0.15.0,
    TensorFlow: 2.0.1

    I've already changed everything. But I still can’t use the demo. Now another error:

    TypeError: float() argument must be a string or a number, not 'google.protobuf.pyext._message.RepeatedScalarContainer'

    The above exception was the direct cause of the following exception:

    Traceback (most recent call last):
    File "C:\Users\Lex\AppData\Local\Programs\Python\Python37\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
    File "C:\Users\Lex\AppData\Local\Programs\Python\Python37\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
    File "C:\Users\Lex\python-envs\sample-env\Scripts\mlagents-learn.exe\__main__.py", line 7, in <module>
    File "c:\users\lex\python-envs\sample-env\lib\site-packages\mlagents\trainers\learn.py", line 495, in main
    run_cli(parse_command_line())
    File "c:\users\lex\python-envs\sample-env\lib\site-packages\mlagents\trainers\learn.py", line 491, in run_cli
    run_training(run_seed, options)
    File "c:\users\lex\python-envs\sample-env\lib\site-packages\mlagents\trainers\learn.py", line 329, in run_training
    tc.start_learning(env_manager)
    File "c:\users\lex\python-envs\sample-env\lib\site-packages\mlagents_envs\timers.py", line 258, in wrapped
    return func(*args, **kwargs)
    File "c:\users\lex\python-envs\sample-env\lib\site-packages\mlagents\trainers\trainer_controller.py", line 205, in start_learning
    self._create_trainers_and_managers(env_manager, new_behavior_ids)
    File "c:\users\lex\python-envs\sample-env\lib\site-packages\mlagents\trainers\trainer_controller.py", line 191, in _create_trainers_and_managers
    self._create_trainer_and_manager(env_manager, behavior_id)
    File "c:\users\lex\python-envs\sample-env\lib\site-packages\mlagents\trainers\trainer_controller.py", line 172, in _create_trainer_and_manager
    trainer.add_policy(name_behavior_id, policy)
    File "c:\users\lex\python-envs\sample-env\lib\site-packages\mlagents\trainers\sac\trainer.py", line 358, in add_policy
    self.optimizer = SACOptimizer(self.policy, self.trainer_parameters)
    File "c:\users\lex\python-envs\sample-env\lib\site-packages\mlagents\trainers\sac\optimizer.py", line 46, in __init__
    super().__init__(policy, trainer_params)
    File "c:\users\lex\python-envs\sample-env\lib\site-packages\mlagents\trainers\optimizer\tf_optimizer.py", line 21, in __init__
    self.create_reward_signals(trainer_params["reward_signals"])
    File "c:\users\lex\python-envs\sample-env\lib\site-packages\mlagents\trainers\optimizer\tf_optimizer.py", line 134, in create_reward_signals
    self.policy, reward_signal, config
    File "c:\users\lex\python-envs\sample-env\lib\site-packages\mlagents\trainers\components\reward_signals\reward_signal_factory.py", line 36, in create_reward_signal
    class_inst = rcls(policy, **config_entry)
    File "c:\users\lex\python-envs\sample-env\lib\site-packages\mlagents\trainers\components\reward_signals\gail\signal.py", line 44, in __init__
    _, self.demonstration_buffer = demo_to_buffer(demo_path, policy.sequence_length)
    File "c:\users\lex\python-envs\sample-env\lib\site-packages\mlagents_envs\timers.py", line 258, in wrapped
    return func(*args, **kwargs)
    File "c:\users\lex\python-envs\sample-env\lib\site-packages\mlagents\trainers\demo_loader.py", line 85, in demo_to_buffer
    demo_buffer = make_demo_buffer(info_action_pair, group_spec, sequence_length)
    File "c:\users\lex\python-envs\sample-env\lib\site-packages\mlagents_envs\timers.py", line 258, in wrapped
    return func(*args, **kwargs)
    File "c:\users\lex\python-envs\sample-env\lib\site-packages\mlagents\trainers\demo_loader.py", line 65, in make_demo_buffer
    demo_processed_buffer, batch_size=None, training_length=sequence_length
    File "c:\users\lex\python-envs\sample-env\lib\site-packages\mlagents\trainers\buffer.py", line 283, in resequence_and_append
    batch_size=batch_size, training_length=training_length
    File "c:\users\lex\python-envs\sample-env\lib\site-packages\mlagents\trainers\buffer.py", line 106, in get_batch
    dtype=np.float32,
    ValueError: setting an array element with a sequence.
     

    Attached Files: