My goal is to train an agent to play MarioKart on the Nintendo DS. My first approach (in theory) was to setup an emulator on my pc and let the agent play for ages. But then a colleague suggested to train the agent first on pre recorded humanly played video data, to achieve some sort of base level. And then for further perfection let the agent play for its own with the emulator.

But I have no clue how training with video data works. E.g. I wonder how to calculate a loss since there is no reward. Or am I getting the intuition wrong?

I would appreciate it if someone could explain this technique to me.


1 Answer 1


In reinforcement learning, to learn off policy control, you need data on the states, actions and rewards at each time step. If, in addition to a recorded video, you had a recording of controller inputs, and could add reward data by hand, then you could use a standard reinforcement learning method, e.g. DQN. Simply run the DQN training loop as normal, but skip the parts where it acts in the environment, and only train on batches of recorded experience.

With only video data, your options are limited. However, it might still be useful, because a significant part of the challenge is a machine vision task. For a DQN agent, it will need to convert frames from the video (e.g. last 4 frames) into a prediction of the different rewards that it could get depending on which controller buttons are pressed. If you can teach a separate neural network to perform a vision task on relevant video data, it may may help. You could use the learned weights from the first layers of this network as the starting point for your Q values network, and it will likely speed up a DQN figuring out the relationship to its predictions. This sort of task switch following learning is called transfer learning, and is often used in computer vision tasks.

A possibly useful starting task if you have a video, but no controller or reward data, would be to predict the next frame(s) of the video, given say four starting frames (you need more than one so that the neural network can use velocity information). It should be possible to generate the training data using opencv or ffmpeg from your recordings.

  • $\begingroup$ So first I train a network to identify important objects? (Can I use tho YOLO network here?) And with the trained identifier I train a second network to predict the next frame from four predecessor frames. But then? And will this really give me an advantage? I can still let the agent play for itselfs. I think I will have enougth work setting up the enviroment and rewards and so on... $\endgroup$
    – Voß
    Dec 19, 2019 at 14:07
  • 1
    $\begingroup$ @bruh: If you have information about the objects available that might be useful as a transfer learning starter and you could use e.g. YOLO. However, my suggestion in the answer is simply to predict the next frame, because you already have that in the video data, so it requires a lot less data preparation. Yes you can start directly with the RL, that is what the DQN authors did for all the Atari games, and it worked well for most of them. However, you asked whether it was possible to learn from just the video, and this answer addresses the original question. $\endgroup$ Dec 19, 2019 at 14:13

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .