Agent does not preform any actions during training
My environment runs fine and the player brain works perfectly, but the agent does not move at all during training. A couple errors happen repeatedly:
NullReferenceException: Object reference not set to an instance of an object EnemyAgent.AgentAction (System.Single[] vectorAction, System.String textAction) (at <36c59ff2250e45b19ec9332a93a4d0cd>:0) Agent.AgentStep () (at <36c59ff2250e45b19ec9332a93a4d0cd>:0) Academy.EnvironmentStep () (at <36c59ff2250e45b19ec9332a93a4d0cd>:0) Academy.FixedUpdate () (at <36c59ff2250e45b19ec9332a93a4d0cd>:0) Exception
and
ArgumentException: An item with the same key has already been added. System.ThrowHelper.ThrowArgumentException (System.ExceptionResource resource) (at <8cdd91c3618b427b905eb298374eee86>:0) System.Collections.Generic.Dictionary2[TKey,TValue].Insert (TKey key, TValue value, System.Boolean add) (at <8cdd91c3618b427b905eb298374eee86>:0) System.Collections.Generic.Dictionary2[TKey,TValue].Add (TKey key, TValue value) (at <8cdd91c3618b427b905eb298374eee86>:0) Brain.SendState (Agent agent, AgentInfo info) (at <36c59ff2250e45b19ec9332a93a4d0cd>:0) Agent.SendInfoToBrain () (at <36c59ff2250e45b19ec9332a93a4d0cd>:0) Agent.SendInfo () (at <36c59ff2250e45b19ec9332a93a4d0cd>:0) Academy.EnvironmentStep () (at <36c59ff2250e45b19ec9332a93a4d0cd>:0) Academy.FixedUpdate () (at <36c59ff2250e45b19ec9332a93a4d0cd>:0) Exception
The vectorAction that is passed into agentAction is full of NaN. I already tried decreasing the learning rate, which did not do anything.
@BenM77 Have you made sure your vector_observations are between -1 and 1 ? It seems it is a null problem, not a NaN problem, maybe the two are separate issues.
@vincentpierre I went back and chekced my vector_observations. This made the errors in the log go away, but I am still getting NaN in the vectorAction array.
I do not know what could be causing this. What branch are you on ? What is the environment like ? Observations? Discrete or continuous actions ? Are you training with PPO or BC ? Do the NaN values appear immediately or after some training. What are the errors you get now ? You said it made the errors go away, but I think NaN values should break a few things...
@vincentpierre I went back and tried the training process again. Still, no errors appear. I am using PPO with continuous observations and actions on the master branch. The NaN values apear immediately and never change.
Hi I have met the similar problems. Do you have any solution now? I got ‘NullReferenceException: Object reference not set to an instance of an object’ in the :Agent sort, which the action is using a function of the main program.
As of 0.4, the continuous actions should be capped between -1 and 1. Can someone tell me if the NaN values still appear in v0.4 ? If they do it could be that the Network diverges which means that the Network tries to push the actions to large values as it gives better rewards. A solution could be to penalize large action values (give a negative reward proportional to the action values). Would it be possible to output the action values in python (modifying take_action in the python/ppo/trainer.py script to print the actions at each step) ? This way, we will know if the network diverges to NaN values or if the NaNs are here from the start.
Same problem: Im able to train my Agents until step 10k. Shortly after that, the Unity Executable as well as in Editor just stop doing anything, since they only receive NaN. My Brain is set to 1000 steps and i cranked up the Academy Steps from 0 to 5000000 without any change overall. My trainer setting have a max step of 5.0e^8. I also tried clamping the actions inside Unity, without any further success.
There is a possibility that the NaN values arise when either the observation or the reward are NaN. This commit catches the NaN values in observations and reward and set them to 0 when it is the case. Can someone try it out and see if the NaNs still appear ?
Hi all,
I am closing this thread due to inactivity. Please feel free to re-open it if desired.
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.