nabacg / deep-rl-navigation-project

0 stars 0 forks source link

Error when using continuos mode! #1

Open Leterax opened 5 years ago

Leterax commented 5 years ago

only changed made to the Training.ipynb file are: from mlagents.envs import UnityEnvironment, as the location of UnityEnvironment has changed. Training with the built in ml-agents commandline tool works without any problems.

when initializing the agent with: agent = Agent(state_size=state_size, action_size=action_size, seed=0) where action_size is defined by action_size = brain.vector_action_space_size this error is thrown.

TypeError: new() received an invalid combination of arguments - got (google.protobuf.pyext._message.RepeatedScalarContainer, int), but expected one of:
 * (torch.device device)
 * (torch.Storage storage)
 * (Tensor other)
 * (tuple of ints size, torch.device device)
      didn't match because some of the arguments have invalid types: (google.protobuf.pyext._message.RepeatedScalarContainer, int)
 * (object data, torch.device device)
      didn't match because some of the arguments have invalid types: (google.protobuf.pyext._message.RepeatedScalarContainer, int)

this is because action_size is of the type: <class 'google.protobuf.pyext._message.RepeatedScalarContainer'>. When initializing the agent with: agent = Agent(state_size=state_size, action_size=action_size[0], seed=0) no error is thorwn, as now an int is passed. However when training with scores = train_agent(agent, env, output_weights= "new_model_weights.pth", target_mean_score=30, n_episodes=20000) this error is thrown. UnityActionException: There was a mismatch between the provided action and the environment's expectation: The brain Learning_Brain_02 expected 4 continuous action(s), but was provided: [3.0]

nabacg commented 5 years ago

Hi, thanks for trying out my project! You are not using one of those environments prebuilt by Udacity as explained in this section, are you?
I suspect the interface might have been simplified and the brain.vector_action_space_size does return an int, not _message.RepeatedScalarContainer. That would explain the first error. So fixing it like that might address this particular problem:

agent = Agent(state_size=state_size, action_size=4, seed=0)

Having said that, if interface with Unity env has changed I suspect you might run into more issues. I assume here that all data exchanged between env and agent (State, Action, Reward etc) are standard numpy arrays, if that is no longer true there will be more errors.