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

Why is BC offline training so slow? (Imitation learning)

Open oseq opened this issue 7 years ago • 15 comments

Hello i huge problem with offline BC training, that i already mentioned in one of my comments. Traning with BC offline is very slow 😞 Reaching 1000 setps takes around 5 minutes, while for the same configuration in RL i reach 1000 steps in 40s. While training editor seems very laggy like it has been played in 1 FPS (i have target frame rate set to 30). It doesnt seems like problem with my computer because looking at hardware monitor it does not have big load. Setting time scale above 1 only makes it worse. For time scale 30 it seems like 0.2 FPS. I am using CPU version of Tensorflow. My current configuration is:

trainer: offline_bc max_steps: 2.0e5 batch_size: 128 summary_freq: 1000 max_steps: 5.0e4 batches_per_epoch: 20 use_recurrent: false hidden_units: 256 learning_rate: 5.0e-4 num_layers: 4 sequence_length: 128 memory_size: 1024 demo_path: ./UnitySDK/Assets/Demonstrations/file.demo

thanks in advance for Your help

oseq avatar Jan 03 '19 18:01 oseq

Have you tried to increase the decision frequency of your agents? The higher the value, the less often the agent will have to calculate a new decision so you probably will see a performance improvement.

image

Nevak avatar Jan 04 '19 16:01 Nevak

@Nevak Thanks it helped a bit, i guess BC algorithm is just less effective than PPO ant thats because it is taking more time form one to another step.

oseq avatar Jan 04 '19 17:01 oseq

HI @oseq

Offline BC works fundamentally differently from PPO. While the simulation happens slower, training is not any slower. This is because the network is being updated using the offline demonstration data many times every step of the simulation.

awjuliani avatar Jan 07 '19 18:01 awjuliani

@awjuliani Thanks for your resonse. So basicly it hard to directlty compare this two metods in terms of trening steps. For me RL yelds much better resaults than IL (despite i am working on car controll, which is a problem that is suitablefor IL). I have a problem: in BC i algorithm reach certain point which is not satisfying and than results drops, becameing even worse and not recovering from it. Do you maybe have some advice for me?

Here is graph. Red one is RL and pink one is IL. Both in same environment, both for learning time: 2 hours. graph

oseq avatar Jan 07 '19 18:01 oseq

Hi @oseq

Bad performance is BC may be due to a demonstration which is too small in size. Can I ask how many examples/episodes you collected for the training data?

awjuliani avatar Jan 07 '19 18:01 awjuliani

@awjuliani Yeah sure, i have set of 14 runs with 8500 expieriences. My brain parameters are:

Vector observation size: 60 (using ray perception) Num Stacked Vector obs: 3 Vector Action Size: 2 [continuous] No visual obs.

So that may be to small set. I will try with bigger one. Do you have any suggestions?

Thank you, for your help 👍

oseq avatar Jan 07 '19 18:01 oseq

For BC 8500 may still be too few. We are working on a new Imitation Learning algorithm that will be able to learn from many fewer examples, but unfortunately that won't be released for another couple months.

awjuliani avatar Jan 07 '19 19:01 awjuliani

@awjuliani ok so i will provide bigger set. Good to know that you working on better algorithm, sadly i have to do my comparative thesis now. I'm keeping my fingers crossed for you guys :)

oseq avatar Jan 07 '19 19:01 oseq

We are working on a new Imitation Learning algorithm that will be able to learn from many fewer examples

Tight!

BartMartner avatar Jan 09 '19 14:01 BartMartner

At the risk of sounding totally ignorant, I am still not quite clear why we need a simulation running (i.e. Unity scene) during BC training if we already have recorded training data? In other words, isn't the recorded [observation, action] enough to train our model within python/TF?

hyounesy avatar Jan 18 '19 01:01 hyounesy

Same, hyounesy.

BartMartner avatar Jan 18 '19 01:01 BartMartner

Experiencing the same thing with : number of experiences : 39828 episodes 10 mean reward 23.3

whiteGhost333 avatar Feb 22 '19 04:02 whiteGhost333

@hyounesy - this is a good point. I'm re-tagging this issue as a feature request because it makes sense.

mmattar avatar Apr 03 '19 19:04 mmattar

Hi all,

The simulation in Offline BC trainer exists to provide a test-time measure of performance.

We also have a new imitation learning method, GAIL, which performs much better when there are only small amounts of demonstration data. I would recommend taking a look at that.

Closing this issue for now.

awjuliani avatar Sep 16 '19 17:09 awjuliani

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.

github-actions[bot] avatar Jan 29 '21 06:01 github-actions[bot]