2

I'm doing a regression problem and I have 18 features. Whenever I try to predict the values, it always gives me negative values. Can anybody help?

I define my NN to be this:

features = Input(shape=(18,))

LAYER1

X = Dense(1024)(features)
X = BatchNormalization()(X)
X = Dropout(0.1)(X)
X = LeakyReLU(alpha=0.2)(X)

LAYER2

X = Dense(1024)(X)
X = BatchNormalization()(X)
X = Dropout(0.1)(X)
X = LeakyReLU(alpha=0.2)(X)

LAYER3

X = Dense(1024)(X)
X = BatchNormalization()(X)
X = Dropout(0.1)(X)
X = LeakyReLU(alpha=0.2)(X)

LAYER4

X = Dense(512)(X)
X = BatchNormalization()(X)
X = Dropout(0.1)(X)
X = LeakyReLU(alpha=0.2)(X)

LAYER5

X = Dense(256)(X)
X = BatchNormalization()(X)
X = Dropout(0.1)(X)
X = LeakyReLU(alpha=0.2)(X)

LAYER6

X = Dense(128)(X)
X = BatchNormalization()(X)
X = Dropout(0.1)(X)
X = LeakyReLU(alpha=0.2)(X)

output

Corr = Dense(1)(X)
model = Model(inputs = features, outputs=Corr)
model.compile(optimizer = 'Sgd', loss=huber_loss, metrics=['mse', 'mae'])
model.fit(X_train, y_train, validation_data=(X_test, y_test), epochs=20, batch_size=512, verbose=1)

where Huber loss is:

def huber_loss(y_true, y_pred): 
    return tf.losses.huber_loss(y_true,y_pred)
Shai
  • 111,146
  • 38
  • 238
  • 371
  • Please show us what kind of data you are working with – HitLuca May 30 '18 at 08:29
  • Also, in this cases try the simplest model first (like just a Dense(1) layer) and if it works improve on it, so you know at which point you get the problem – HitLuca May 30 '18 at 08:31
  • my features are a set of floats (particle physics quantities like pt, eta, etc..). Anyway, thanks I'll give it a try. – Pocholo Mendiola May 30 '18 at 08:37
  • Python `int` not equal `C_int` , Python(x64)(0xFFFF) = 65535, C(X86)(0xFFFF) = -1, another point : `64 bit OS int != 32 bit OS int`. I try fixed this error right now but need drink some coffee. – dsgdfg May 30 '18 at 10:00
  • But you can fix this with **USE 32BIT PYTHON** – dsgdfg May 30 '18 at 10:08

0 Answers0