Created
October 17, 2015 17:06
-
-
Save ieee8023/136b4ba1dedd23bf003f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
OutputStream fos = Files.newOutputStream(Paths.get("coefficients.bin")); | |
ObjectOutputStream dos = new ObjectOutputStream(fos); | |
dos.writeObject(model.params()); | |
dos.flush(); | |
dos.close(); | |
FileUtils.write(new File("conf.json"), model.getLayerWiseConfigurations().toJson()); | |
MultiLayerConfiguration confFromJson = MultiLayerConfiguration.fromJson(FileUtils.readFileToString(new File("conf.json"))); | |
ObjectInputStream dis = new ObjectInputStream(new FileInputStream("coefficients.bin")); | |
INDArray newParams = (INDArray) dis.readObject(); | |
dis.close(); | |
MultiLayerNetwork savedNetwork = new MultiLayerNetwork(confFromJson); | |
savedNetwork.init(); | |
savedNetwork.setParameters(newParams); | |
System.out.println("Original network params " + model.params()); | |
System.out.println("Restored network params " + savedNetwork.params()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment