Reputation: 548
In the keras-ocr example, they are using CTC loss function. In the model compile line,
# the loss calc occurs elsewhere, so use a dummy lambda function for the loss
model.compile(loss={'ctc': lambda y_true, y_pred: y_pred}, optimizer=sgd)
they are using a dummy lambda function with y_true,y_pred as inputs and y_pred as output. But y_pred was already defined previously as the softmax activation.
y_pred = Activation('softmax', name='softmax')(inner)
If y_pred is softmax activation then where is CTC loss being used?. Does y_pred mean the output of the last previous layer, in keras irrespective of whether it has already been defined?. (because in the code, the layer's output just before the compile line is CTC loss).
Upvotes: 3
Views: 2020
Reputation: 23556
As it is said in the comment, the loss calculation is already done somewhere else, so the {'ctc': lambda y_true, y_pred: y_pred}
just takes already pre-calculated loss in y_pred
and discards y_true
as not needed without any calculations.
Upvotes: 3