I have loss function which implemented for siamese network. In Keras if you have to build your own loss function, it should only take input arguments as (y_true, y_pred). But in my case I have y_pred1, y_pred1, y_true1(class_label), y_true2(class_label), y_true3(similarity label)
So my solution is to concatenate what I have like:
def my loss ( y_true, y_pred):
y_true1 = y_true[:, 0]
y_true2 = y_true[:, 1]
label = y_true[:, 2]
y_pred1 = y_pred[:, 0]
y_pred2 = y_pred[:, 1]
The second problem is, I have one parameter (alpha) which is a function of current epoch number that I should pass it to the loss function also.
In general , if you have to pass some another argument you can use the wrapper function as the solution suggested here.
But it will not help me in my case , because my alpha should be change depending on the current number of epoch. It is basically the Sigmoied function of the current epoch.
The only way that I can track the epoch number is inside my own generator, because I have dataset built in tfrecords. So I am using my own generator to feed the data to model.
So any one have any idea what should I do? How I can track the current epoch number and use it.