Alternative to Lambda layer in Keras

660 views Asked by At

I try to convert the Keras OCR example into a CoreML model.

I already can train my slightly modified model and everything looks good in Python. But now I want to convert the model into CoreML to use it my iOS app.

The problem is, that the CoreML file format can't support Lambda layers. I am not an expert in this field, but as far as I understand, the Lambda layer here is used to calculate the loss using ctc_batch_cost(). The layer is created around line 464. I guess this is used for greater precision over the "build in" loss functions.

Is there any way the model creation can be rewritten to fit the layer set CoreML supports? I have no idea which output layer type to use for the model.

1

There are 1 answers

1
Matthijs Hollemans On BEST ANSWER

Cost functions usually aren't included in the CoreML model, since CoreML only does inference while cost functions are used for training. So strip out that layer before you export the model and you should be good to go.