How to use PyBrain?

PyBrain is a Python-based library for creating neural networks. I looked at the tutorials on my site, but they don't seem to help me much. The simulation that I plan to do is to have a car that is driving along the highway, equipped with 5 range finders, showing the current distance between it and the walls, between 0.0 and 1.0 . Fitness is based on medium speed. (Higher will be better). The output will be a single number, how much you are turning at this particular moment, where everything is correct: 1.0 , and everything else is either -1.0 or 0.0 , depending on what makes it easier.

I assume that using this setting, I will have 5 input neurons and 1 output neuron. For example, suppose I have 4 hidden neurons. Suppose also that I made a function called runSimulation() , which takes the neural network as an argument, drives the car on the course using this neural network, and returns the average speed (fitness).

How can I train a neural network based on the repeated results of runSimulation() ?


I hope I explain it correctly (not to mention at least a little to know what I'm doing), but if I don’t, tell me please.

+6
source share
1 answer

This seems to be a controlled learning problem. In this type of problem you MUST give some answers BEFORE training your NN.

You can try the following approach

  • Create a simple maze for your car.
  • Drive the car manually in this maze.
  • Collect turn information.

Suppose you have the following machine.

  • rf = rangefinder
  • rf_f = rangefinder_forward
  • rf_r = rangefinder_right
  • rf_l = rangefinder_left
  • rf_60 = rangefinder_60 degree
  • rf_320 = rangefinder_320 degree

Below is your RF diagram

  320 f 60 \ | / \ | / \ |/ l--------------r | | | 

Your train set should be as follows.

 rf_f , rf_l , rf_r, rf_60, rf_320 , turn 0 0 0 0 0 0 0 // we go directly, no obstacles detected 0 0 0 0 0 0 0 // we go directly, , no obstacles detected 1.0 0 0 0 0 0 0 // We see a wall in forward far away. 0.9 1 0 0 0 0 0.2 // We see a wall in forward and left, therefore turn right slightly etc. 0.8 0.8 0 0 0 0 0.4 // We see a wall in forward and left, therefore turn right slightly etc. 

Once you have provided such a training dataset to your NN, you can train it.

+9
source

Source: https://habr.com/ru/post/899409/


All Articles