ml-agents icon indicating copy to clipboard operation
ml-agents copied to clipboard

ValueError with reshaping arrays

Open fast8wild opened this issue 8 years ago • 2 comments

As I was about to train my agents, I ran into an error with the following traceback:

ValueError Traceback (most recent call last) in () 56 info = env.reset(train_mode=train_model, progress=get_progress())[brain_name] 57 # Decide and take an action ---> 58 new_info = trainer.take_action(info, env, brain_name, steps, normalize) 59 info = new_info 60 trainer.process_experiences(info, time_horizon, gamma, lambd) C:\ml-agents-master\python\ppo\trainer.py in take_action(self, info, env, brain_name, steps, normalize) 73 self.stats['entropy'].append(ent) 74 self.stats['learning_rate'].append(learn_rate) ---> 75 new_info = env.step(actions, value={brain_name: value})[brain_name] 76 self.add_experiences(info, new_info, epsi, actions, a_dist, value) 77 return new_info C:\ml-agents-master\python\unityagents\environment.py in step(self, action, memory, value) 438 self._conn.send(b"STEP") 439 self._send_action(action, memory, value) --> 440 return self._get_state() 441 elif not self._loaded: 442 raise UnityEnvironmentException("No Unity environment is loaded.") C:\ml-agents-master\python\unityagents\environment.py in _get_state(self) 290 self._brains[b].state_space_type, 291 len(state_dict["states"]))) --> 292 memories = np.array(state_dict["memories"]).reshape((n_agent, self._brains[b].memory_space_size)) 293 rewards = state_dict["rewards"] 294 dones = state_dict["dones"] ValueError: cannot reshape array of size 1 into shape (1,0)

From what I can tell, this the result of me having two Brains in the environment. However, one of the brains (the second) is heuristic, so naturally I do not see a point in it passing it through the Python API. I am not sure how to alter the code to suit this given condition, so any assistance would be appreciated.

fast8wild avatar Jan 14 '18 16:01 fast8wild

Ok I found a solution by disabling the broadcast option for the heuristic brain.

fast8wild avatar Jan 14 '18 16:01 fast8wild

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

lock[bot] avatar Jan 04 '20 20:01 lock[bot]