Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Cannot train two duplicated characters

Discussion in 'ML-Agents' started by ivandiegorodriguez, May 27, 2020.

  1. ivandiegorodriguez

    ivandiegorodriguez

    Joined:
    May 27, 2020
    Posts:
    1
    I have a character made of two agents that contains two different brains. The code is working perfectly but I have a problem when I try to clone the characters in order to train them faster.

    ************ This is the error: **************

    Sensor sizes much match.
    UnityEngine.Debug:Assert(Boolean, String)
    MLAgents.Sensor.SensorShapeValidator:ValidateSensors(List`1) (at /home/ivan/ml-agents-0.14.0/ml-agents/com.unity.ml-agents/Runtime/Sensor/SensorShapeValidator.cs:37)
    MLAgents.RpcCommunicator:putObservations(String, AgentInfo, List`1) (at /home/ivan/ml-agents-0.14.0/ml-agents/com.unity.ml-agents/Runtime/Grpc/RpcCommunicator.cs:245)
    MLAgents.RemotePolicy:RequestDecision(AgentInfo, List`1) (at /home/ivan/ml-agents-0.14.0/ml-agents/com.unity.ml-agents/Runtime/Policy/RemotePolicy.cs:34)
    MLAgents.Agent:SendInfoToBrain() (at /home/ivan/ml-agents-0.14.0/ml-agents/com.unity.ml-agents/Runtime/Agent.cs:526)
    MLAgents.Agent:SendInfo() (at /home/ivan/ml-agents-0.14.0/ml-agents/com.unity.ml-agents/Runtime/Agent.cs:780)
    MLAgents.Academy:EnvironmentStep() (at /home/ivan/ml-agents-0.14.0/ml-agents/com.unity.ml-agents/Runtime/Academy.cs:392)
    MLAgents.AcademyFixedUpdateStepper:FixedUpdate() (at /home/ivan/ml-agents-0.14.0/ml-agents/com.unity.ml-agents/Runtime/Academy.cs:32)


    ************** This is the output from ml-learn: *****************


    Version information:
    ml-agents: 0.14.0,
    ml-agents-envs: 0.14.0,
    Communicator API: API-14,
    TensorFlow: 2.0.1
    INFO:mlagents_envs:Listening on port 5004. Start training by pressing the Play button in the Unity Editor.
    INFO:mlagents_envs:Connected new brain:
    My Behavior?team=0
    Process Process-1:
    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 "/home/ivan/anaconda3/envs/mlagent.0.14/lib/python3.6/multiprocessing/process.py", line 258, in _bootstrap
    self.run()
    File "/home/ivan/anaconda3/envs/mlagent.0.14/lib/python3.6/multiprocessing/process.py", line 93, in run
    self._target(*self._args, **self._kwargs)
    File "/home/ivan/anaconda3/envs/mlagent.0.14/lib/python3.6/site-packages/mlagents/trainers/subprocess_env_manager.py", line 143, in worker
    env.reset()
    File "/home/ivan/anaconda3/envs/mlagent.0.14/lib/python3.6/site-packages/mlagents_envs/environment.py", line 297, in reset
    self._update_state(rl_output)
    File "/home/ivan/anaconda3/envs/mlagent.0.14/lib/python3.6/site-packages/mlagents_envs/environment.py", line 282, in _update_state
    agent_info_list, self._env_specs[brain_name]
    File "/home/ivan/anaconda3/envs/mlagent.0.14/lib/python3.6/site-packages/mlagents_envs/timers.py", line 262, in wrapped
    return func(*args, **kwargs)
    File "/home/ivan/anaconda3/envs/mlagent.0.14/lib/python3.6/site-packages/mlagents_envs/rpc_utils.py", line 166, in batched_step_result_from_proto
    _process_vector_observation(obs_index, obs_shape, agent_info_list)
    File "/home/ivan/anaconda3/envs/mlagent.0.14/lib/python3.6/site-packages/mlagents_envs/timers.py", line 262, in wrapped
    return func(*args, **kwargs)
    File "/home/ivan/anaconda3/envs/mlagent.0.14/lib/python3.6/site-packages/mlagents_envs/rpc_utils.py", line 128, in _process_vector_observation
    dtype=np.float32,
    ValueError: setting an array element with a sequence.
    INFO:mlagents.trainers:Learning was interrupted. Please wait while the graph is generated.
    INFO:mlagents.trainers:Saved Model


    As I said before when I train one character (two agents with two brains) everything is fine but as far as I clone them I have this error. I have checked that the state and action sizes are correct so I don't know what else to do.

    Thanks for any help!
     
  2. TreyK-47

    TreyK-47

    Unity Technologies

    Joined:
    Oct 22, 2019
    Posts:
    1,816
    I'll kick this over to the team for them to have a look!
     
  3. didekdms123

    didekdms123

    Joined:
    Oct 27, 2020
    Posts:
    1
    I had the same error as the example above.
    Can you tell me how you solved it?
     
  4. celion_unity

    celion_unity

    Joined:
    Jun 12, 2019
    Posts:
    289
    @didekdms123 That would happen if you have two agents with the same Behavior Name but with different sized sensors, or different values for their Behavior Parameters > Vector Observations > Space Size. You need to make sure that all agents with the same Behavior Name have identical observation shapes.