title: Hot to extract keras model data to MATLAB
body: <p>I do not have the deep learning toolbox of Matlab. I want to implement only the classification part in MATLAB. I would train the network in Keras and save the model in JSON and h5 format. Finally, load the Jason and h5 formatted data from MATLAB and use the model to predict a test sample.</p>
  <p>I have created and saved a binary classifier with one layer model using Keras as follows:</p>
  <pre><code>model.add(keras.layers.Dense(25, input_dim=232, activation='relu'))
  model.add(keras.layers.Dense(1, activation='sigmoid'))
  model_json = model.to_json()
  with open(&quot;model.json&quot;, &quot;w&quot;) as json_file:
      json_file.write(model_json)
  model.save_weights(&quot;model.h5&quot;)
  </code></pre>
  <p>Next I can read the Json file from MATLAB:</p>
  <pre><code>fid = fopen(fileName); % Opening the file
  raw = fread(fid,inf); % Reading the contents
  str = char(raw'); % Transformation
  fclose(fid); % Closing the file
  data = jsondecode(str); % 
  </code></pre>
  <p>Now how can I build the model in MATLAB to predict a sample? How weights and biases are stored in JSON of the h5 file?</p>
  <p>Any comments would be appreciated.</p>