Pocholo Mendiola
Pocholo Mendiola

Reputation: 21

I always predict negative values with my model

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)

Upvotes: 2

Views: 1305

Answers (0)

Related Questions