AndrejGobeX / TrackMania_AI

Racing game AI
GNU General Public License v3.0
99 stars 11 forks source link

Understanding the learning process #13

Closed SzymonResiak closed 2 years ago

SzymonResiak commented 2 years ago

Hi, could you add me on Discord? I have no idea how else can i contact you directly. szymci#4551

AndrejGobeX commented 2 years ago

Post the issue here, it could be useful to others

SzymonResiak commented 2 years ago

Okay, i was wondering whats your accuracy was with each of Drivers. I tried to retrain those ai's but im not sure if i get it correctly. And if models are trained from 0 after me running for example 'python Trainer.py Maniack 100'? Output was about 30% accuracy. I am currently working with google's Inception v3 model and trying to figure out how do i train the model in the way i could see the learning process. Train model, test it in game, train again and on and on until the moment im satisfied. At the end i would love to get two different models trained and point the differences in learning process. Its just how i decided i will learn more to understand ai.

AndrejGobeX commented 2 years ago

I think it was 70-90%. I used the images on the repo. If you are using Inception v3 or other google's nets, check a quick tutorial for that network and use the images from this repo as a dataset. I tried to put everything together, bur you are free to use your own scripts. But that is all snapshots od my driving, basically accuracy would mean how good it mimics my driving. So you shouldn't worry too much on that part.

SzymonResiak commented 2 years ago

So what was the training process in your case, was it just simply 'python train.py (engine name) no_epoch'? And then if you want your driver to be better you train again and again? What im trying to figure out is that, if there is a way to show the process of learning, the generations.

AndrejGobeX commented 2 years ago

So, for supervised nets yes, I just did python train. I did a colab training with the notebook in the repo. I do not remember how much I have trained or how much I tweaked the dataset etc. Epochs if I remember I put 5000 or more, it does require a lot of training. You can use tensorboard or other methods to monitor training. Because the problem is a bit different than the usual, accuracy won't help you much. Of course, you want to get at least 70% for example, but it still depends a lot. If you run it on a completely different track, it might be better to actually get a lower score, because it will generalize more and be faster. If you would have a bigger dataset, with "perfect" keystrokes, then the accuracy would make more sense, and then you would plot the learning. I am not a perfect driver in trackmania, so an accuracy of 100% literally means the ai will make the same mistakes I did (but then again, an AI better than human cannot be achieved through supervised learning). At first I did this for fun, and didn't pay attention to those details hahaha. But if this helps, cool. Let me know if you made a better net!

SzymonResiak commented 2 years ago

I will for sure play around it tomorror or in this weekend, your work really motivates to educate in this area. For that thanks a lot. Will post here what im able to achieve :) For now im changing the name of Issue to "understanding the learning process" maybe someone else wants to learn from your work.

AndrejGobeX commented 2 years ago

But for NEAT and SAC, the process is totally different, and here the training can be much more useful. Thanks for the feedback!

SzymonResiak commented 2 years ago

Hi, did all the training for Neptune. Eventually i created my own screenshots while i was checking how it works, but, i found a problem. After training i actually got 0.96 accuracy, but when i run Driver.py it doesnt move. I can see that script is working because 1st time i press S, it doesnt drive back. Any clue what i did wrong? Maybe i messed up training.

AndrejGobeX commented 2 years ago

I do not have any idea, did you use first person? Also check the screenshots and try to dubug the code. The script captures fullscreen, but you can use the other script for a windowed capture, plus its faster

SzymonResiak commented 2 years ago

I did check screenshots they were all taken in 1920x1080, also retrained the model but still no movement. Any chance you can look at it via Discord or something like that, then ill leave a note here for others what went wrong?

AndrejGobeX commented 2 years ago

I am not active right now, have a lot of things to do... Are you changing the focus to the game? Alt-tab to the game, the terminal should not be visible if fullscreen. Try debugging or at least print inputs and outputs before and after the prediction and see whats wrong.