Skip to content

Array conversions

NotGayBut5CentsAre5Cents edited this page Jun 5, 2018 · 1 revision

array_conversions.py

This file has 3 methods for various conversions of the training data you record.

convert_to_one_hot

one hot means that only one value in the list can be 1 the params are:

filepath   # the path which the new data will be saved

train_data # a npy array with the recorded data, the train data is a 2 by x array 
           # and on the first column are the images, on the second are the choices 
           # that were made in a form of a list.

This method just converts the choices in the given format:

               A  W  S  D                                    A  W  S  D WA WD SA SD 
from choice = [x, x, x, x]           to     result_choice = [x, x, x, x, x, x, x, x]

and then creates a new npy array and saves it to the given path filepath.

shorten_data

the params are:

filepath   # the path which the new data will be saved

train_data # a npy array with the recorded data, the train data is a 2 by x array 
           # and on the first column are the images, on the second are the choices 
           # that were made in a form of a list.

This method expect the choices to be in the form of long one hot array and will convert it to a shorter representation as follows:

This method just converts the choices in the given format:

                       A  W  S  D WA WD SA SD                          A  W  D                                   
from  result_choice = [x, x, x, x, x, x, x, x]       to      choice = [x, x, x] 

This method doesnt convert the S choice

short_to_one_hot

the params are:

filepath   # the path which the new data will be saved

train_data # a npy array with the recorded data, the train data is a 2 by x array 
           # and on the first column are the images, on the second are the choices 
           # that were made in a form of a list.

This methods expect the choices to be not one hot and will convert it to one hot array representation:

      choice = [x, x, x]       to one hot version result_choice = [x, x, x] # where only one values can 
                                                                            # be 1 and the others need to be zeroes

e.g(if i have pressed w and a the non one hot version will be choice = [1, 1, 0] and will be converted to [1, 0, 0]) The priority is at follows when converting A>D>W.

Clone this wiki locally