Skip to content

Instantly share code, notes, and snippets.

@LplusKira
Created December 17, 2015 02:28
Show Gist options
  • Save LplusKira/6922e9456d3a74687134 to your computer and use it in GitHub Desktop.
Save LplusKira/6922e9456d3a74687134 to your computer and use it in GitHub Desktop.
val conf: MultiLayerConfiguration = new NeuralNetConfiguration.Builder()
.regularization(true).l2(2e-6)
.seed(luckyseed)
.iterations(20)
.list(3)
...
.build();
val iter: DataSetIterator = new GDataSetIteratorTrain(...)
while( iter.hasNext() ){
val eachbatch: DataSet = iter.next()
model.fit(eachbatch)
}
val coefficient_bin = "coefficient.bin"
val conf_json = "conf.json"
val fos: OutputStream = Files.newOutputStream(Paths.get(coefficient_bin))
val dos = new DataOutputStream(fos)
Nd4j.write(model.params(), dos)
dos.flush()
dos.close()
FileUtils.writeStringToFile(new File(conf_json), model.getLayerWiseConfigurations().toJson())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment