Implementing a Natural Language Classifier in iOS with Keras + Core ML

(Jeff_L) #1

4. Check that your prompt changed to:


(SwiftNLC) $

5. Launch Jupyter Notebook:


jupyter notebook

6. Open your browser to:


http://localhost:

To create a basic model with Keras/TensorFlow and export it with


CoreMLTools, open createModelWithNSLinguisticTaggerEmbedding in


your Jupyter browsing session and execute any cells in order to create,


save, and export the Keras Model using Core ML exporting tools.


The basic Core ML model will be saved in the current folder.


Keras / TensorFlow model consideration


As discussed above, the Swift Embedder project is generally responsible


for massaging the dataset, and responsible in particular for creating the


one-hot word encoding for stem words from sample utterances and for


creating a corpus of stemmed, encoded documents to be used for


training the model.


For this reason, the Python code to create the model is simplied with


very little pre-processing, and it quickly starts to create the TensorFlow


model used for learning.


This model is a simple, fully connected network that receives as input


an array of embedded 0's and 1's for each sample utterance. It uses


‘relu’ as an activator for the rst and an internal hidden layer, and then


at the end, as this is a multi-class classier, it uses ‘softmax’ to


emphasize the winner prediction.

Free download pdf