diff --git a/n2s3_examples/src/main/scala/fr/univ_lille/cristal/emeraude/n2s3/apps/ExampleMnistPrune1Epoch.scala b/n2s3_examples/src/main/scala/fr/univ_lille/cristal/emeraude/n2s3/apps/ExampleMnistPrune1Epoch.scala index 820d6283bee81a2f9fe358e8574078844c77ef3b..8e0a627a58441a315f26a46283b90a356783ea5b 100755 --- a/n2s3_examples/src/main/scala/fr/univ_lille/cristal/emeraude/n2s3/apps/ExampleMnistPrune1Epoch.scala +++ b/n2s3_examples/src/main/scala/fr/univ_lille/cristal/emeraude/n2s3/apps/ExampleMnistPrune1Epoch.scala @@ -50,17 +50,17 @@ object ExampleMnistPrune1Epoch extends App { var NeuroneLabels = List[(Int, String)]() var logger: SimMongoLog = null var log = false - var prune = false + var prune = true var globalIteration = 6 var sizeChunk = 10000 - - for(x <- 1 to 1) { + var networksizes = Array(10,20,50,100,500) + for(x <- 4 to 4) { implicit val timeout = Config.longTimeout alpha = ArrAlpha((x - 1) / 5) beta = ArrBeta((x - 1) % 5) alpha = 0.05F beta = 0.1F - SimName = "400N" + "-" + x + SimName = networksizes(x - 1)+"N" + "-" + x println("a:" + alpha + " b:" + beta) QBGParameters.alf_m = 0.005f QBGParameters.alf_p = 0.01f @@ -70,6 +70,7 @@ object ExampleMnistPrune1Epoch extends App { var iteration = 0 var CropInfo = "" var duration: Long = 0L + var Totalduration: Long = 0L var simTime = "" var benchmarkMonitor: BenchmarkMonitorRef = null n2s3 = new N2S3("N2S3") @@ -96,7 +97,7 @@ object ExampleMnistPrune1Epoch extends App { val unsupervisedLayer = n2s3.createNeuronGroup() .setIdentifier("OutLayer") - .setNumberOfNeurons(400) + .setNumberOfNeurons(networksizes(x - 1)) .setNeuronModel(LIF, Seq( (MembranePotentialThreshold, 35 millivolts))) @@ -145,9 +146,10 @@ object ExampleMnistPrune1Epoch extends App { val dataTestFile = N2S3ResourceManager.getByName("mnist-test-images").getAbsolutePath val labelTestFile = N2S3ResourceManager.getByName("mnist-test-labels").getAbsolutePath - + simTime = "" + Totalduration = System.currentTimeMillis() while (iteration <= globalIteration) { - simTime = "" + unsupervisedLayer.unfixNeurons() n2s3.first = false stream = InputMnist.DataParts(dataFile, labelFile, sizeChunk*(iteration-1), sizeChunk) @@ -159,22 +161,21 @@ object ExampleMnistPrune1Epoch extends App { logger = new SimMongoLog(n2s3, listOfConnexions, SimName.split("-")(0), true, true, true, true, "MNIST", SimTime,SynapseIndex) } duration = System.currentTimeMillis() - simTime = "Train " + iteration + simTime = simTime + "Train " + iteration n2s3.runAndWait() - println(System.currentTimeMillis() - duration) simTime = simTime + " | " + (System.currentTimeMillis() - duration) + "\n" if (iteration == globalIteration && log) { logger.storeSimInfoAndDestroy() } - println("saving : " + System.currentTimeMillis()) - NetworkSaving.save(n2s3, croppedCnx, SynapseIndex, folderName + "/" + SimName + " Arch " + iteration) - println("end : " + System.currentTimeMillis()) - println("saving cropped : " + System.currentTimeMillis()) - saveNeurones(unsupervisedLayer, "[" + iteration + "]") - println("end : " + System.currentTimeMillis()) + //println("saving : " + System.currentTimeMillis()) + //NetworkSaving.save(n2s3, croppedCnx, SynapseIndex, folderName + "/" + SimName + " Arch " + iteration) + //println("end : " + System.currentTimeMillis()) + //println("saving cropped : " + System.currentTimeMillis()) + //saveNeurones(unsupervisedLayer, "[" + iteration + "]") + //println("end : " + System.currentTimeMillis()) /* inputStream.append(InputMnist.DataFrom(dataTestFile, labelTestFile)) @@ -204,6 +205,7 @@ object ExampleMnistPrune1Epoch extends App { println("cropping : " + System.currentTimeMillis()) CropInfo = cropNetwork(inputLayer, Ratio) println("end : " + System.currentTimeMillis()) + simTime = simTime + "cropped " + "[" + iteration + "]" + " with " + Ratio + "\n" // cropInput(n2s3.inputLayerRef.get, Ratio) } @@ -229,7 +231,7 @@ object ExampleMnistPrune1Epoch extends App { NetworkSaving.save(n2s3, croppedCnx, SynapseIndex, folderName + "/" + SimName + " Arch " + iteration + " cropped") benchmarkMonitor.exportToHtmlView(folderName + "/" + "test cropped " + SimName + " [" + iteration + "]" + ".html") - + simTime = simTime + "Total time: " + (System.currentTimeMillis() - Totalduration) + "\n" benchmarkMonitor.saveCrops(folderName + "/" + "Sim " + SimName + " info a:" + alpha + " b:" + beta, simTime, CropInfo + " Ratio " + Ratio) } if (iteration == globalIteration && log) { @@ -238,7 +240,9 @@ object ExampleMnistPrune1Epoch extends App { iteration += 1 } } + //logger.destroy() + n2s3.destroy() sys.exit(0)