I'm trying to build a toy model which can identify a constant difference between two variables:
(if variable1- variable2>10 then 1 else 0).
This should be a quite simple task for any regression model, but I want to solve it with NN. However all simple NN I built can not give me more than 51% accuracy.
Is this something that I do not understand?
seed = 7 np.random.seed(seed) x1 = np.arange(50000) x2 = x1+10+(0.5-np.random.rand(len(x1))) X = np.column_stack((x1,x2)) Y = (x2-x1)>10 encoder = LabelEncoder() encoder.fit(Y) encoded_Y = encoder.transform(Y) train_X, test_X, train_y, test_y = train_test_split( X, Y, train_size=0.9, random_state=0) model = Sequential() model.add(Dense(2, input_dim=2,activation='relu')) model.add(Dense(16, activation='relu')) model.add(Dense(1, activation='sigmoid')) model.compile(optimizer=RMSprop(lr=0.001), loss=binary_crossentropy, metrics=[binary_accuracy]) history = model.fit(train_X, train_y, epochs=1000, batch_size=10, validation_data=(test_X, test_y), verbose=1)