I have recently stumbled upon an article on the CoreML docs site that discusses an implementation of a recurrent model for predicting text. I am trying to replicate this, or at least something similar, and have hit a wall as to how the author was able to define the "stateIn" input in the model as optional. Does anyone have any info that may point me in the right direction? I'm building the network using keras and plan on converting to CoreML after training.
The process used in this article would apply perfectly to my model. Outputting the state of the last layer and passing it back into the model for the next item in the sequence seems like a great approach, however I am unclear on how this is achievable using CoreML.
Any information or help would be greatly appreciated!
Thanks ahead of time
Link to the article: https://developer.apple.com/documentation/coreml/core_ml_api/making_predictions_with_a_sequence_of_inputs
It doesn't look like the coremltools Keras converter lets you specify which inputs are optional.
However, the proto files that contain the MLModel definition say that a Model object has a ModelDescription, which has an array of FeatureDescription object for the inputs, which has a FeatureType object, which has an isOptional boolean.
So something like this should work:
mlmodel = keras.convert(...)
spec = mlmodel._spec
spec.description.input[1].type.isOptional = True
mlmodel.save(...)
I didn't actually try this, so the exact syntax may be different, but this is the general idea.