-1

I'm trying to normalize a dataset for a neural network, in the dataset are negatives and positives values that can go from -inf to +inf. I need to normalize the negatives values between 0,0.5 and the positive values between 0.5,1 but the normalized data can never reach 0 or 1 because they are -inf and +inf respectvely.

Can i do this with python?

Sorry for my rusty english and if this question may seem dumb, but i´m really struggling with this math.

CypherX
  • 7,019
  • 3
  • 25
  • 37
  • What, exactly, are your requirements? Should the normalization always normalize the same input to the same output, regardless of what else is in the data set? Should the normalization always result in the lowest and highest normalized outputs being 0 and 1? It is not possible for a normalization method to have both of those properties. – user2357112 Oct 15 '19 at 02:28

2 Answers2

1

You could use the sigmoid function.

Sigmoid function
import numpy as np

def sigmoid(x):
  return 1 / (1 + np.exp(-x))

But sigmoid is the not the only function which does this. Check out tanh(x) as well.

tanh(x) = (exp(x) - exp(-x))/(exp(x) - exp(-x)) = sigmoid(2x) - sigmoid(-2x)

Reference

How to calculate a logistic sigmoid function in Python?

CypherX
  • 7,019
  • 3
  • 25
  • 37
0

Take a look at sigmoid function

jackc
  • 56
  • 4