Skip to content

Instantly share code, notes, and snippets.

@thomprycejones
Created December 4, 2016 20:55
Show Gist options
  • Save thomprycejones/3b08d9e60d00311670f964bc7456b336 to your computer and use it in GitHub Desktop.
Save thomprycejones/3b08d9e60d00311670f964bc7456b336 to your computer and use it in GitHub Desktop.
// Get the model
DataInputStream dis = new DataInputStream(new FileInputStream(MODEL_path));
INDArray newParams = Nd4j.read(dis);
dis.close();
// Open the model
MultiLayerNetwork deserializedModel = ModelSerializer.restoreMultiLayerNetwork(dis);
// Get the imageFile (sized 28x28) and convert to INDArray
NativeImageLoader nativeImageLoader = new NativeImageLoader();
INDArray indArray = nativeImageLoader.asMatrix(imageFile);
// Do the magic (we have to sort it!)
deserializedModel.output(indArray).data();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment