Recreating python feature extraction code in JavaScript
So TensorFlow's new Preprocessing Layers will make the use of models from python in TensorFlow.js much easier. At the moment those layers are only available in python, not JavaScript, so there is some transcription to be done.
The original model was trained by creating a windowed dataset with a sequence length of 5. In order to get prediction working in the browser that code needs to be replicated.
Now my model loading function has changed to include a loop which loads a set of JSON files. There are 4 of these required to get the model predicting and to make sense of the predictions. So that code looks like this:
My first pass at preparing the dataset just used the words as elements of a list. However I need to support the idea of tuples of word, POS pairs, so I modified the data code to look like this:
Then I went through each of the 11 input features and converted the python code to JavaScript. That is quite tricky and there are still some bugs in there, so I will fix that up tomorrow and hopefully have a working part of speech tagger.
Comments
Post a Comment