title: Implementing Keras Model into website with Keras.js
body: <p>I have been trying to implement a basic Keras model generated in Python into a website using the <a href="https://github.com/transcranial/keras-js" rel="nofollow noreferrer">Keras.js</a> library. Now, I have the model trained and exported into the <code>model.json</code>, <code>model_weights.buf</code>, and <code>model_metadata.json</code> files. Now, I essentially copied and pasted test code from the github page to see if the model would load in browser, but unfortunately I am getting errors. Here is the test code. (EDIT: I fixed some errors, see below for remaining ones.)</p>
  
  <pre><code>var model = new KerasJS.Model({
      filepaths: {
          model: 'dist/model.json',
          weights: 'dist/model_weights.buf',
          metadata: 'dist/model_metadata.json'
    },
    gpu: true
  });
  
      model.ready()
    .then(function() {
      console.log("1");
      // input data object keyed by names of the input layers
      // or `input` for Sequential models
      // values are the flattened Float32Array data
      // (input tensor shapes are specified in the model config)
      var inputData = {
        'input_1': new Float32Array(data)
      };
      console.log("2 " + inputData);
      // make predictions
      return model.predict(inputData);
    })
    .then(function(outputData) {
      // outputData is an object keyed by names of the output layers
      // or `output` for Sequential models
      // e.g.,
      // outputData['fc1000']
      console.log("3 " + outputData);
    })
    .catch(function(err) {
      console.log(err);
      // handle error
    });
  </code></pre>
  
  <p>EDIT: So I changed my program around a little to be compatible with JS 5 (that was a stupid mistake on my part), and now I have encountered a different error. This error is caught and then is logged. The error I get is: <code>Error: predict() must take an object where the keys are the named inputs of the model: input.</code> I believe this problem arises because my <code>data</code> variable is not in the correct format. I thought that if my model took in a 28x28 array of numbers, then <code>data</code> should also be a 28x28 array so that it could correctly "predict" the right output. However, I believe I am missing something and that is why the error is being thrown. <a href="https://stackoverflow.com/questions/42744588/keras-model-predict-fails">This</a> question is very similar to mine, however it is in python and not JS. Again, any help would be appreciated. </p>