Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inappropriate Min-max scaling in demo_controller #33

Open
wzy1935 opened this issue Oct 9, 2023 · 0 comments
Open

Inappropriate Min-max scaling in demo_controller #33

wzy1935 opened this issue Oct 9, 2023 · 0 comments

Comments

@wzy1935
Copy link

wzy1935 commented Oct 9, 2023

Hi, I'm debugging my assignment 2 code, and I find this issue. Maybe you would want to take a look at it?

In demo_controller.py, the control method does a min-max scaling:

def control(self, inputs, controller):
    # Normalises the input using min-max scaling
    inputs = (inputs-min(inputs))/float((max(inputs)-min(inputs)))

The problem is that min-max scaling should be done on the entire data set, not on individual inputs, otherwise, it will result in distorted data ranges.

In this case, this scaler will completely shadow the inputs[2] and input[3] because the original value range of these two is [-1, 1], while all other value ranges are wider than [-400, 400] based on my test. This means that after scaling, the original value of inputs[2] and inputs[3] won't matter because it is not significantly big enough compared to other values. This is bad because these two inputs represent "player's direction" and "enemy's direction", but now these two values in this case can not be recognized by NN.

The following graph is an illustration. I collected some data from the sensor to draw this figure, the y-axis is the scaled inputs[2], and the x-axis is calculated without original inputs[2] and inputs[3]. They show a directly proportional relationship with k=1, meaning that they are basically the same and the scaled inputs[2] is irrelevant with inputs[2] from the sensor.

image

I'll suggest to change it to something like this, which will make the scaling more resonable:

def control(self, inputs, controller):
    # inputs_range represents real range for each inputs from sensor
    inputs_range = np.array([[-700, 700], [-400, 400], [-1.0, 1.0], [-1.0, 1.0], [-700, 700], [-400, 400],
                             [-700, 700], [-400, 400], [-700, 700], [-400, 400], [-700, 700], [-400, 400],
                             [-700, 700], [-400, 400], [-700, 700], [-400, 400], [-700, 700], [-400, 400],
                             [-700, 700], [-400, 400]])
    inputs = (inputs-inputs_range[:,0])/float((inputs_range[:,1]-inputs_range[:,0]))

Maybe you would want to fix this after the assignment 2 finished? Since lots of groups already working on their project based on this NN structure.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant