I am creating a binary classifier in Keras and here's the code
model = Sequential()
model.add(Dense(30, input_dim=60, activation='relu'))
model.add(Dense(1, activation='tanh'))
model.compile(loss='mse', optimizer='adam', metrics=['accuracy'])
The problem though, is that I have variable targets, i.e. they lie between -1 and 1. And here is a histogram of the distibution of my targets
I know that this still, could work very well for me, and the model would probably be able to predict the variable outputs, the input data is very complex, and the model might not be able to train to predict the exact outputs. I am perfectly okay of the model cannot predict the exact values, as a long as the sign of the output [-1,1] is correct.
So I thought what if the loss function gave zero loss for a prediction that has the correct sign, but gave whatever the required binary loss is, if the output has the wrong sign, this way, during training it would give importance to the highly incorrect predictions, but as soon as the sign of the predictions are right (just what I need), it doesn't consider them anymore, hopefully giving a better result. The catch here is, that if I just trained it to predict the signs of the targets, it would give all of the inputs equal importance
So my question is, does any such loss function exist in Keras or anywhere else, or do I have to create my own loss function? If I have to create my own loss function, how do I do it?