I am trying to model a neural network where the output of the network is checked and assigned a score based on the gold data. For example: if the predicted label of the network is in a predefined set, then the loss should be low (for example loss = 0.0), otherwise, the loss should be high (for example loss = 1.0).
I wonder how I can model this loss function in order to apply gradient descent to update network weights. As my understanding, we usually calculate loss directly from the predicted output, which is different to my case because I calculate the loss with a condition on the predicted label.
The workflow of my network is like this:
predicted_label = NeuralNetwork(input)
if predicted_label in [A, B, C]:
loss = 0
else:
loss = 1
Have you ever seen similar models before? Or do you have any suggestion for modelling this kind of network?
Thank you very much in advance.