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

Some questions about imitation learning.

Open oseq opened this issue 7 years ago • 9 comments

Hello, i am trying to use my teacher for learning with imitation learning. Sadly its not working great for now.

My enviroment is a simple car (agent) with 120 vector space obeseravtion gathered by ray cast (Ray Perception). My environment is a car track (fenced with walls) with some obstacles .For config I am using default imitation learning settings. Training went well with reinforcement learning, but i have some problems with imitation learning, trained models seems to not allways receate my movement, even if enviroment is not changing between the episodes. Additionally they seems to have some good recreation tries of my behaiour but after that in other trial fails compleatly.

This concuded me to some questions about imitation learning:

  1. Is imitation learning process imitates the teacher but also mesures how he is rewarded for an actions, or rather ignores rewards system compleatly?
  2. When and how often shold i reset the buffer with BC Teacher Helper? I didnt use that option, because as i understand it is some kind of reseting agents memory.
  3. Is model build based on best trys (in terms of i.e. cumulative rewars ) or based on last trial before training ends

Thanks in advance for responses!

oseq avatar Dec 30 '18 18:12 oseq

In (plain) Behaviour Cloning (BC), we want to "clone" a teacher; we don't care about its performance or its cumulative reward. The teacher is like a black box function which receives observation vector and gives an action. We use a neural network to learn this function(which maps observation to actions).

There are some researches in the field of imitation learning regarding learning a "Reward Function" from a teacher, and I think it is not in the scope of ML-Agent's BC model.

About your question, I think the trainer uses all data in the demonstration file, see here and here

What is your Cloning Loss after training? I think the default BC model in ML-Agents uses two up to four hidden layers, have you tried to change the number of layers or increasing number of epochs?

taesiri avatar Dec 30 '18 20:12 taesiri

@taesiri Thank you for your responce 😊

Currently i am using offline on ML-Agents v0.6 training, my current settings are:

trainer: offline_bc batch_size: 3000 summary_freq: 1000 max_steps: 5.0e4 batches_per_epoch: 10 use_recurrent: false hidden_units: 128 learning_rate: 5.0e-4 num_layers: 3 sequence_length: 64 memory_size: 512 demo_path: ./UnitySDK/Assets/Demonstrations/file.demo

In my enviroment in ideal sistuation (when i test it with PlayerBrain) it should took 3000 setps for agent to compleat one lap of track. I am using Continuous control with size of 2 (one for rotation, one for acceleration). Agent is observing using 120 observation sapce (20 lasers that can recognise 4 types of objects: obstacles, walls, road and terrain). (Maybe i should decrease number of lasers?)

For parameters: Should i try to increase number of layers? You also mentioned increasing number of epochs but i dont see this parameter in bc offline config. Is it possible to change that value? BTW Where i can find documentation for parameters used by BC, i only found descrption about PPO parameters?

What is interesing my summary looks very messy: (blob:https://i.imgur.com/VNaqKRe.jpg) Often first run of traning is much better than later ones :(

What is also wierd while training with offline bc i notice that training is very slow and increasing time scale in academy does not increase training speed like in reinforcement learning but only makes me lose big number of FPS (it is dropping to around 0.5 FPS for time scale=30, ). It seems to lag unity a lot, while my hardware seems to work only little loaded (around 65% of CPU usage). I dont have this issue while training with RL.

Thanks in advance for responses!

oseq avatar Jan 02 '19 16:01 oseq

Why is offline bc training sooo slow?

superjayman avatar Jan 03 '19 14:01 superjayman

@superjayman is it also very slow for you?

oseq avatar Jan 03 '19 14:01 oseq

@taesiri update: i set new set of hyperparameters and now training statistics looks much more promising, but still i have issue with very long time to get each step of training in comparison to reinforcement learning.

Here is TSB results after 1:40h of training: screen

oseq avatar Jan 03 '19 20:01 oseq

Actually, for BC you don't need to have access to the environment unless you want to record rewards. I am not sure why there is no option in the BC model for doing this. In every iteration, you are executing an action and recording the reward. But this doesn't explain the slowness of your training.

About parameters, always look at the code. This line suggests there is an argument for the number of epochs, but I haven't found any usage of this parameter in BC trainer.

taesiri avatar Jan 03 '19 21:01 taesiri

Related issue: #1532

taesiri avatar Jan 03 '19 21:01 taesiri

Thanks for reaching out to us. Hopefully you were able to resolve your issue. We are closing this due to inactivity, but if you need additional assistance, feel free to reopen the issue.

eshvk avatar Apr 03 '19 22:04 eshvk

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 Apr 04 '20 08:04 lock[bot]