title: TensorFlow.js speed in the browser
body: <p>I've trained a simple bidirectional LSTM network in Keras (20 units) and exported the model via</p>
  
  <pre><code>tfjs.converters.save_keras_model(model, 'myModel')
  </code></pre>
  
  <p>The model is 53kb large. In my JavaScript app, I load the model like this</p>
  
  <pre><code>var model;
  async function loadModel() {;
      model = await tf.loadModel('https://example.com/myModel.json');
  }
  </code></pre>
  
  <p>and afterwards I run my predictions with</p>
  
  <pre><code>async function predict(input) {
      var pred = model.predict(input);
      ...
  }
  </code></pre>
  
  <p>It takes 5-6 seconds till the model is loaded, this is fine. But what bothers me is that every call of predict() also takes 5-6 seconds. Every time. For my use case, I'd need the prediction to be extremely fast, 1 second or less.</p>
  
  <p>My question is: Is this normal? Or is something wrong with my code?</p>
  
  <p><em>Edit: Here is a codepen: <a href="https://codepen.io/anon/pen/XygXRP" rel="nofollow noreferrer">https://codepen.io/anon/pen/XygXRP</a></em></p>
  
  <p>BTW, model.predict is blocking the UI - how can I prevent that?</p>