diff --git a/n2s3/src/main/scala/fr/univ_lille/cristal/emeraude/n2s3/features/logging/SimMongoLog.scala b/n2s3/src/main/scala/fr/univ_lille/cristal/emeraude/n2s3/features/logging/SimMongoLog.scala index b57383483bda861b30024c5dad8fe48a7441300c..f21491dfd8ce5d1d872c2e4a8fc5f0fbec899ef8 100644 --- a/n2s3/src/main/scala/fr/univ_lille/cristal/emeraude/n2s3/features/logging/SimMongoLog.scala +++ b/n2s3/src/main/scala/fr/univ_lille/cristal/emeraude/n2s3/features/logging/SimMongoLog.scala @@ -24,7 +24,7 @@ import scala.sys.process._ */ -class SimMongoLog(n2s3 : N2S3,list : IndexedSeq[IndexedSeq[IndexedSeq[ConnectionPath]]],name : String, Spikes : Boolean, Potential : Boolean, Label : Boolean,SynapticWeight : Boolean,Data:String,time: String,SynapseIndex : List[(Integer, Integer, Integer)]) { +class SimMongoLog(n2s3 : N2S3,list : IndexedSeq[IndexedSeq[IndexedSeq[ConnectionPath]]],name : String, Spikes : Boolean, Potential : Boolean, Label : Boolean,SynapticWeight : Boolean,Data:String,time: String,SynapseIndex : List[(Integer, Integer, Integer)], globalTimestamps: Long) { /** ****************************************************************************************************************** * Setup DB connection & Collection @@ -54,7 +54,6 @@ class SimMongoLog(n2s3 : N2S3,list : IndexedSeq[IndexedSeq[IndexedSeq[Connection var loggerSpike: ActorRef = _ var loggerPotential : ActorRef = _ var loggerLabel : ActorRef = _ - var globalTimestamps = System.currentTimeMillis() /** * Collections diff --git a/n2s3_examples/src/main/scala/fr/univ_lille/cristal/emeraude/n2s3/apps/ExampleFMnistPrune1Epoch.scala b/n2s3_examples/src/main/scala/fr/univ_lille/cristal/emeraude/n2s3/apps/ExampleFMnistPrune1Epoch.scala index 4328535a014b3cdbcf1cb1f44ea4b7acb93ce24c..2fa705bcd06b2f447a4eb86a10c72a539dd4f907 100755 --- a/n2s3_examples/src/main/scala/fr/univ_lille/cristal/emeraude/n2s3/apps/ExampleFMnistPrune1Epoch.scala +++ b/n2s3_examples/src/main/scala/fr/univ_lille/cristal/emeraude/n2s3/apps/ExampleFMnistPrune1Epoch.scala @@ -61,7 +61,7 @@ object ExampleFMnistPrune1Epoch extends App { val formatter = new SimpleDateFormat("dd-MM-yyyy HH:mm:ss") var iteration = 0 var CropInfo = "" - var duration: Long = 0L + var globalTime: Long = 0L var simTime = "" var benchmarkMonitor: BenchmarkMonitorRef = null n2s3 = new N2S3("N2S3") @@ -147,15 +147,15 @@ object ExampleFMnistPrune1Epoch extends App { stream.goto() println("Start Training ... " + "[" + iteration + "]") + globalTime = System.currentTimeMillis() if (iteration == 1 && log) { - logger = new SimMongoLog(n2s3, listOfConnexions, SimName.split("-")(0), true, true, true, true, "FMNIST", SimTime,SynapseIndex) + logger = new SimMongoLog(n2s3, listOfConnexions, SimName.split("-")(0), true, true, true, true, "FMNIST", SimTime,SynapseIndex, globalTime) } - duration = System.currentTimeMillis() simTime = "Train " + iteration n2s3.runAndWait() - println(System.currentTimeMillis() - duration) - simTime = simTime + " | " + (System.currentTimeMillis() - duration) + "\n" + println(System.currentTimeMillis() - globalTime) + simTime = simTime + " | " + (System.currentTimeMillis() - globalTime) + "\n" if (iteration == globalIteration && log) { logger.storeSimInfoAndDestroy() @@ -179,12 +179,12 @@ object ExampleFMnistPrune1Epoch extends App { benchmarkMonitor = n2s3.createBenchmarkMonitor(unsupervisedLayer) - duration = System.currentTimeMillis() - simTime = simTime + "Test " + iteration + "\n" + duration + globalTime = System.currentTimeMillis() + simTime = simTime + "Test " + iteration + "\n" + globalTime n2s3.runAndWait() - simTime = simTime + " | " + (System.currentTimeMillis() - duration) + "\n" + simTime = simTime + " | " + (System.currentTimeMillis() - globalTime) + "\n" benchmarkMonitor.exportToHtmlView(folderName + "/" + "test " + SimName + " [" + iteration + "]" + ".html") benchmarkMonitor.saveCrops(folderName + "/" + "Sim " + SimName + " info a:" + alpha + " no b:" + beta, simTime, " Ratio " + Ratio) @@ -208,14 +208,14 @@ object ExampleFMnistPrune1Epoch extends App { benchmarkMonitor = n2s3.createBenchmarkMonitor(unsupervisedLayer) - duration = System.currentTimeMillis() + globalTime = System.currentTimeMillis() simTime = simTime + "Test cropped " + iteration n2s3.runAndWait() - println(System.currentTimeMillis() - duration) + println(System.currentTimeMillis() - globalTime) - simTime = simTime + " | " + (System.currentTimeMillis() - duration) + "\n" + simTime = simTime + " | " + (System.currentTimeMillis() - globalTime) + "\n" saveNeurones(unsupervisedLayer, "cropped " + "[" + iteration + "]" + " with " + Ratio) NetworkSaving.save(n2s3, croppedCnx, SynapseIndex, folderName + "/" + SimName + " Arch " + iteration + " cropped") diff --git a/n2s3_examples/src/main/scala/fr/univ_lille/cristal/emeraude/n2s3/apps/ExampleFreeWayLogged.scala b/n2s3_examples/src/main/scala/fr/univ_lille/cristal/emeraude/n2s3/apps/ExampleFreeWayLogged.scala index aba94472a0ba56ec6ea814df499705104090bef9..0d903e5a152c0420dd518e1054d726d1d8e884d3 100755 --- a/n2s3_examples/src/main/scala/fr/univ_lille/cristal/emeraude/n2s3/apps/ExampleFreeWayLogged.scala +++ b/n2s3_examples/src/main/scala/fr/univ_lille/cristal/emeraude/n2s3/apps/ExampleFreeWayLogged.scala @@ -47,6 +47,7 @@ object ExampleFreeWayLogged extends App { var logger: SimMongoLog = null var SimName = "Freeway" + var globalTime: Long = 0L var folderName = "" val formatter = new SimpleDateFormat("dd-MM-yyyy HH:mm:ss") var SimTime = formatter.format(new Date()) @@ -97,8 +98,8 @@ object ExampleFreeWayLogged extends App { SynapsesIndex(listOfConnexionsinputToLayer1) // Start logger - - logger = new SimMongoLog(n2s3, listOfConnexionsinputToLayer1, SimName.split("-")(0), true, true, false, true, "FreeWay", SimTime,SynapseIndex) + globalTime = System.currentTimeMillis() + logger = new SimMongoLog(n2s3, listOfConnexionsinputToLayer1, SimName.split("-")(0), true, true, false, true, "FreeWay", SimTime,SynapseIndex, globalTime) println("### Training First Layer ###") retinaStream.append(InputAER.DataFromFile(dataFile).repeat(1))//.repeat(8) @@ -130,7 +131,7 @@ object ExampleFreeWayLogged extends App { } SynapsesIndex(listOfConnexionsinputToLayer2) - logger = new SimMongoLog(n2s3, listOfConnexionsinputToLayer2, SimName.split("-")(0), true, true, false, true, "FreeWay", SimTime,SynapseIndex) + logger = new SimMongoLog(n2s3, listOfConnexionsinputToLayer2, SimName.split("-")(0), true, true, false, true, "FreeWay", SimTime,SynapseIndex, globalTime) retinaStream.append(InputAER.DataFromFile(dataFile).repeat(1)) //.repeat(8) n2s3.runAndWait() diff --git a/n2s3_examples/src/main/scala/fr/univ_lille/cristal/emeraude/n2s3/apps/ExampleMnist2.scala b/n2s3_examples/src/main/scala/fr/univ_lille/cristal/emeraude/n2s3/apps/ExampleMnist2.scala index d98c98ff35a18f0b49b7bdb412c0078f0b56f1ca..1f8c406d6e6b0c55a94300a6ceaeb1ca7260951a 100644 --- a/n2s3_examples/src/main/scala/fr/univ_lille/cristal/emeraude/n2s3/apps/ExampleMnist2.scala +++ b/n2s3_examples/src/main/scala/fr/univ_lille/cristal/emeraude/n2s3/apps/ExampleMnist2.scala @@ -62,190 +62,180 @@ object ExampleMnist2 extends App { var globalIteration = 1 var sizeChunk = 60000 - for(x <- 1 to 1) { - implicit val timeout = Config.longTimeout - alpha = ArrAlpha((x - 1) / 5) - beta = ArrBeta((x - 1) % 5) - alpha = 0.05F - beta = 0.1F - SimName = "20N" + "-" + x - println("a:" + alpha + " b:" + beta) - QBGParameters.alf_m = 0.005f - QBGParameters.alf_p = 0.01f - QBGParameters.beta_m = 2f - QBGParameters.beta_p = 2f - val formatter = new SimpleDateFormat("dd-MM-yyyy HH:mm:ss") - var iteration = 0 - var CropInfo = "" - var duration: Long = 0L - var simTime = "" - var benchmarkMonitor: BenchmarkMonitorRef = null - n2s3 = new N2S3("N2S3") - - /** Vars of Threshold **/ - - CTotal = 0F - CRmaining = 0F - Ratio = 0F - - /** **/ - - folderName = "" - SynapseIndex = List.empty - croppedCnx = List.empty - NeuroneLabels = List.empty - - //val inputLayer = n2s3.createInput(Mnist.distributedInput("data/train2k-images.idx3-ubyte", "data/train2k-labels.idx1-ubyte")) - val inputLayer = n2s3.createInput(inputStream) - val dataFile = N2S3ResourceManager.getByName("mnist-train-images").getAbsolutePath - val labelFile = N2S3ResourceManager.getByName("mnist-train-labels").getAbsolutePath - var stream: MnistFileInputStreamP = null - //inputStream.append(stream) - - val unsupervisedLayer1 = n2s3.createNeuronGroup() - .setIdentifier("Layer1") - .setNumberOfNeurons(20) - .setNeuronModel(LIF, Seq( - (MembranePotentialThreshold, 35 millivolts))) - - val unsupervisedLayer2 = n2s3.createNeuronGroup() - .setIdentifier("Layer2") - .setNumberOfNeurons(10) - .setNeuronModel(LIF, Seq( - (MembranePotentialThreshold, 35 millivolts))) - - inputLayer.connectTo(unsupervisedLayer1, new FullConnection(() => new SimplifiedSTDP())) - var Layer1WTAconnection = unsupervisedLayer1.connectTo(unsupervisedLayer1, new FullConnection(() => new InhibitorySynapse())) + implicit val timeout = Config.longTimeout + alpha = 0.05F + beta = 0.1F + SimName = "20N" + println("a:" + alpha + " b:" + beta) + QBGParameters.alf_m = 0.005f + QBGParameters.alf_p = 0.01f + QBGParameters.beta_m = 2f + QBGParameters.beta_p = 2f + val formatter = new SimpleDateFormat("dd-MM-yyyy HH:mm:ss") + var iteration = 0 + var CropInfo = "" + var globalTime: Long = 0L + var simTime = "" + var benchmarkMonitor: BenchmarkMonitorRef = null + n2s3 = new N2S3("N2S3") + + /** Vars of Threshold **/ + + CTotal = 0F + CRmaining = 0F + Ratio = 0F + + /** **/ + + folderName = "" + SynapseIndex = List.empty + croppedCnx = List.empty + NeuroneLabels = List.empty + + //val inputLayer = n2s3.createInput(Mnist.distributedInput("data/train2k-images.idx3-ubyte", "data/train2k-labels.idx1-ubyte")) + val inputLayer = n2s3.createInput(inputStream) + val dataFile = N2S3ResourceManager.getByName("mnist-train-images").getAbsolutePath + val labelFile = N2S3ResourceManager.getByName("mnist-train-labels").getAbsolutePath + var stream: MnistFileInputStreamP = null + //inputStream.append(stream) + + val unsupervisedLayer1 = n2s3.createNeuronGroup() + .setIdentifier("Layer1") + .setNumberOfNeurons(5) + .setNeuronModel(LIF, Seq( + (MembranePotentialThreshold, 35 millivolts))) + + val unsupervisedLayer2 = n2s3.createNeuronGroup() + .setIdentifier("Layer2") + .setNumberOfNeurons(5) + .setNeuronModel(LIF, Seq( + (MembranePotentialThreshold, 35 millivolts))) + + inputLayer.connectTo(unsupervisedLayer1, new FullConnection(() => new SimplifiedSTDP())) + var Layer1WTAconnection = unsupervisedLayer1.connectTo(unsupervisedLayer1, new FullConnection(() => new InhibitorySynapse())) + + n2s3.create() + + iteration = 1 + inputLayer.neurons.toList.foreach(n => { + CTotal += n.group.connections.length + }) + CTotal = CTotal * unsupervisedLayer1.neurons.size + CRmaining = CTotal + + //showHeatMap(inputLayer,unsupervisedLayer1) + SynapsesIndexInput(inputLayer, unsupervisedLayer1) + SimTime = formatter.format(new Date()) + folderName = SimName.split("-")(0) + SimTime + new File(folderName).mkdir() + + + var inputToClassifierIndex = new ConnectionIndex(inputLayer, unsupervisedLayer1) + var listOfConnexions = for (outputIndex <- 0 until unsupervisedLayer1.shape.getNumberOfPoints) yield { + for (inputX <- 0 until InputMnist.shape.dimensions(0)) yield { + for { + inputY <- 0 until InputMnist.shape.dimensions(1) + input = inputLayer.getNeuronPathAt(inputX, inputY) + output = unsupervisedLayer1.getNeuronPathAt(outputIndex) + if inputToClassifierIndex.getConnectionsBetween(input, output).nonEmpty + } yield inputToClassifierIndex.getConnectionsBetween(input, output).head + } + } - n2s3.create() + val dataTestFile = N2S3ResourceManager.getByName("mnist-test-images").getAbsolutePath + val labelTestFile = N2S3ResourceManager.getByName("mnist-test-labels").getAbsolutePath - iteration = 1 - inputLayer.neurons.toList.foreach(n => { - CTotal += n.group.connections.length - }) - CTotal = CTotal * unsupervisedLayer1.neurons.size - CRmaining = CTotal - //showHeatMap(inputLayer,unsupervisedLayer1) - SynapsesIndexInput(inputLayer, unsupervisedLayer1) - SimTime = formatter.format(new Date()) - folderName = SimName.split("-")(0) + " [" + x + "] " + SimTime - new File(folderName).mkdir() + simTime = "" + // L1 + unsupervisedLayer1.unfixNeurons() + stream = InputMnist.DataParts(dataFile, labelFile, sizeChunk, sizeChunk) + inputStream.append(stream) + println("Start Training L1") - var inputToClassifierIndex = new ConnectionIndex(inputLayer, unsupervisedLayer1) - var listOfConnexions = for (outputIndex <- 0 until unsupervisedLayer1.shape.getNumberOfPoints) yield { - for (inputX <- 0 until InputMnist.shape.dimensions(0)) yield { - for { - inputY <- 0 until InputMnist.shape.dimensions(1) - input = inputLayer.getNeuronPathAt(inputX, inputY) - output = unsupervisedLayer1.getNeuronPathAt(outputIndex) - if inputToClassifierIndex.getConnectionsBetween(input, output).nonEmpty - } yield inputToClassifierIndex.getConnectionsBetween(input, output).head - } + globalTime = System.currentTimeMillis() + if (log) { + logger = new SimMongoLog(n2s3, listOfConnexions, SimName.split("-")(0), true, true, true, true, "MNIST", SimTime, SynapseIndex,globalTime) } + simTime = "Train L1" + n2s3.runAndWait() - val dataTestFile = N2S3ResourceManager.getByName("mnist-test-images").getAbsolutePath - val labelTestFile = N2S3ResourceManager.getByName("mnist-test-labels").getAbsolutePath + println(System.currentTimeMillis() - globalTime) + simTime = simTime + " | " + (System.currentTimeMillis() - globalTime) + "\n" + if (log) { + logger.storeSimInfoAndDestroy() + } - simTime = "" - // L1 - unsupervisedLayer1.unfixNeurons() - stream = InputMnist.DataParts(dataFile, labelFile, sizeChunk, sizeChunk) - inputStream.append(stream) - - println("Start Training L1") - - if (log) { - logger = new SimMongoLog(n2s3, listOfConnexions, SimName.split("-")(0), true, true, true, true, "MNIST", SimTime, SynapseIndex) - } - duration = System.currentTimeMillis() - simTime = "Train L1" - n2s3.runAndWait() - - println(System.currentTimeMillis() - duration) - simTime = simTime + " | " + (System.currentTimeMillis() - duration) + "\n" - - if (log) { - logger.storeSimInfoAndDestroy() - } + // L2 + unsupervisedLayer1.fixNeurons() + Layer1WTAconnection.disconnect() - // L2 - unsupervisedLayer1.fixNeurons() - Layer1WTAconnection.disconnect() + unsupervisedLayer1.connectTo(unsupervisedLayer2, new FullConnection(() => new SimplifiedSTDP())) + var Layer2WTAconnection = unsupervisedLayer2.connectTo(unsupervisedLayer2, new FullConnection(() => new InhibitorySynapse())) + n2s3.first = false + stream = InputMnist.DataParts(dataFile, labelFile, sizeChunk, sizeChunk) + inputStream.append(stream) - unsupervisedLayer1.connectTo(unsupervisedLayer2, new FullConnection(() => new SimplifiedSTDP())) - var Layer2WTAconnection = unsupervisedLayer2.connectTo(unsupervisedLayer2, new FullConnection(() => new InhibitorySynapse())) - n2s3.first = false - stream = InputMnist.DataParts(dataFile, labelFile, sizeChunk, sizeChunk) - inputStream.append(stream) + println("Start Training L2") + + var layerTolayerIndex = new ConnectionIndex(unsupervisedLayer1, unsupervisedLayer2) + var listOfConnexions2 = for (outputIndex <- 0 until unsupervisedLayer2.shape.getNumberOfPoints) yield { + for (_ <- 0 until 1) yield { + for { + inputIndex <- 0 until unsupervisedLayer1.shape.getNumberOfPoints + input = unsupervisedLayer1.getNeuronPathAt(inputIndex) + output = unsupervisedLayer2.getNeuronPathAt(outputIndex) + if layerTolayerIndex.getConnectionsBetween(input, output).nonEmpty + } yield layerTolayerIndex.getConnectionsBetween(input, output).head + }} + + SynapsesIndex(unsupervisedLayer1, unsupervisedLayer2) + + if (log) { + logger = new SimMongoLog(n2s3, listOfConnexions2, SimName.split("-")(0), true, true, true, true, "MNIST", SimTime, SynapseIndex, globalTime) + } + simTime = "Train L2" + n2s3.runAndWait() - println("Start Training L2") - - var layerTolayerIndex = new ConnectionIndex(unsupervisedLayer1, unsupervisedLayer2) - var listOfConnexions2 = for (outputIndex <- 0 until unsupervisedLayer2.shape.getNumberOfPoints) yield { - for (_ <- 0 until 1) yield { - for { - inputIndex <- 0 until unsupervisedLayer1.shape.getNumberOfPoints - input = unsupervisedLayer1.getNeuronPathAt(inputIndex) - output = unsupervisedLayer2.getNeuronPathAt(outputIndex) - if layerTolayerIndex.getConnectionsBetween(input, output).nonEmpty - } yield layerTolayerIndex.getConnectionsBetween(input, output).head - }} - - SynapsesIndex(unsupervisedLayer1, unsupervisedLayer2) - - if (log) { - logger = new SimMongoLog(n2s3, listOfConnexions2, SimName.split("-")(0), true, true, true, true, "MNIST", SimTime, SynapseIndex) - } - duration = System.currentTimeMillis() - simTime = "Train L2" - n2s3.runAndWait() - - println(System.currentTimeMillis() - duration) - simTime = simTime + " | " + (System.currentTimeMillis() - duration) + "\n" - - if (prune) { - Ratio = Ratio + (alpha * (CRmaining / CTotal)) - println("Ratio " + Ratio) - println("cropping : " + System.currentTimeMillis()) - CropInfo = cropNetwork(inputLayer, Ratio) - println("end : " + System.currentTimeMillis()) - // cropInput(n2s3.inputLayerRef.get, Ratio) - } + if (log) { + logger.storeSimInfoAndDestroy() + } + println(System.currentTimeMillis() - globalTime) + simTime = simTime + " | " + (System.currentTimeMillis() - globalTime) + "\n" + + if (prune) { + Ratio = Ratio + (alpha * (CRmaining / CTotal)) + println("Ratio " + Ratio) + println("cropping : " + System.currentTimeMillis()) + CropInfo = cropNetwork(inputLayer, Ratio) + println("end : " + System.currentTimeMillis()) + // cropInput(n2s3.inputLayerRef.get, Ratio) + } - // Testing - inputStream.append(InputMnist.DataFrom(dataTestFile, labelTestFile)) + // Testing + inputStream.append(InputMnist.DataFrom(dataTestFile, labelTestFile)) - println("Start Testing cropped " + "[" + iteration + "]" + " with " + Ratio) + println("Start Testing cropped " + "[" + iteration + "]" + " with " + Ratio) - benchmarkMonitor = n2s3.createBenchmarkMonitor(unsupervisedLayer1) + benchmarkMonitor = n2s3.createBenchmarkMonitor(unsupervisedLayer1) - duration = System.currentTimeMillis() - simTime = simTime + "Test cropped " + iteration + simTime = simTime + "Test cropped " + iteration - n2s3.runAndWait() + n2s3.runAndWait() - println(System.currentTimeMillis() - duration) + println(System.currentTimeMillis() - globalTime) - simTime = simTime + " | " + (System.currentTimeMillis() - duration) + "\n" + simTime = simTime + " | " + (System.currentTimeMillis() - globalTime) + "\n" - //saveCroppedSynapses(unsupervisedLayer1, "cropped " + "[" + iteration + "]" + " with " + Ratio) - //NetworkSaving.save(n2s3, croppedCnx, SynapseIndex, folderName + "/" + SimName + " Arch " + iteration + " cropped") + benchmarkMonitor.exportToHtmlView(folderName + "/" + "test cropped " + SimName + " [" + iteration + "]" + ".html") - benchmarkMonitor.exportToHtmlView(folderName + "/" + "test cropped " + SimName + " [" + iteration + "]" + ".html") + if (log) { + logger.storeBenchmarkTestInfo(benchmarkMonitor) + } - //benchmarkMonitor.saveCrops(folderName + "/" + "Sim " + SimName + " info a:" + alpha + " b:" + beta, simTime, CropInfo + " Ratio " + Ratio) - - if (log) { - logger.storeBenchmarkTestInfo(benchmarkMonitor) - logger.storeSimInfoAndDestroy() - } - } - //logger.destroy() n2s3.destroy() - sys.exit(0) def showHeatMap(inputL: InputNeuronGroupRef, layer : NeuronGroupRef): Unit ={ diff --git a/n2s3_examples/src/main/scala/fr/univ_lille/cristal/emeraude/n2s3/apps/ExampleMnistCompression.scala b/n2s3_examples/src/main/scala/fr/univ_lille/cristal/emeraude/n2s3/apps/ExampleMnistCompression.scala index 1c54d94a4c27858ef1760f03b32d8b2a0feb20d4..b92c34fb5a1a4ccf167dda6def5ecd6033001bf2 100755 --- a/n2s3_examples/src/main/scala/fr/univ_lille/cristal/emeraude/n2s3/apps/ExampleMnistCompression.scala +++ b/n2s3_examples/src/main/scala/fr/univ_lille/cristal/emeraude/n2s3/apps/ExampleMnistCompression.scala @@ -63,7 +63,7 @@ object ExampleMnistCompression extends App { val formatter = new SimpleDateFormat("dd-MM-yyyy HH:mm:ss") var iteration = 0 var CropInfo = "" - var duration: Long = 0L + var globalTime: Long = 0L var simTime = "" var benchmarkMonitor: BenchmarkMonitorRef = null n2s3 = new N2S3("N2S3") @@ -150,14 +150,14 @@ object ExampleMnistCompression extends App { println("Start Training ... " + "[" + iteration + "]") if (iteration == 1 && log) { - logger = new SimMongoLog(n2s3, listOfConnexions, SimName.split("-")(0), true, true, true, true, "MNIST", SimTime,SynapseIndex) + logger = new SimMongoLog(n2s3, listOfConnexions, SimName.split("-")(0), true, true, true, true, "MNIST", SimTime,SynapseIndex, globalTime) } - duration = System.currentTimeMillis() + globalTime = System.currentTimeMillis() simTime = "Train " + iteration n2s3.runAndWait() - println(System.currentTimeMillis() - duration) - simTime = simTime + " | " + (System.currentTimeMillis() - duration) + "\n" + println(System.currentTimeMillis() - globalTime) + simTime = simTime + " | " + (System.currentTimeMillis() - globalTime) + "\n" if (iteration == globalIteration && log) { logger.storeSimInfoAndDestroy() @@ -181,12 +181,12 @@ object ExampleMnistCompression extends App { benchmarkMonitor = n2s3.createBenchmarkMonitor(unsupervisedLayer) - duration = System.currentTimeMillis() - simTime = simTime + "Test " + iteration + "\n" + duration + globalTime = System.currentTimeMillis() + simTime = simTime + "Test " + iteration + "\n" + globalTime n2s3.runAndWait() - simTime = simTime + " | " + (System.currentTimeMillis() - duration) + "\n" + simTime = simTime + " | " + (System.currentTimeMillis() - globalTime) + "\n" benchmarkMonitor.exportToHtmlView(folderName + "/" + "test " + SimName + " [" + iteration + "]" + ".html") benchmarkMonitor.saveCrops(folderName + "/" + "Sim " + SimName + " info a:" + alpha + " no b:" + beta, simTime, " Ratio " + Ratio) @@ -210,14 +210,14 @@ object ExampleMnistCompression extends App { benchmarkMonitor = n2s3.createBenchmarkMonitor(unsupervisedLayer) - duration = System.currentTimeMillis() + globalTime = System.currentTimeMillis() simTime = simTime + "Test cropped " + iteration n2s3.runAndWait() - println(System.currentTimeMillis() - duration) + println(System.currentTimeMillis() - globalTime) - simTime = simTime + " | " + (System.currentTimeMillis() - duration) + "\n" + simTime = simTime + " | " + (System.currentTimeMillis() - globalTime) + "\n" saveNeurones(unsupervisedLayer, "cropped " + "[" + iteration + "]" + " with " + Ratio) NetworkSaving.save(n2s3, croppedCnx, SynapseIndex, folderName + "/" + SimName + " Arch " + iteration + " cropped") diff --git a/n2s3_examples/src/main/scala/fr/univ_lille/cristal/emeraude/n2s3/apps/ExampleMnistCompressionStatic.scala b/n2s3_examples/src/main/scala/fr/univ_lille/cristal/emeraude/n2s3/apps/ExampleMnistCompressionStatic.scala index 082b7538a87ccd37e72e5a9af961af4c7b8fd5f4..0c71c03029ff357bf86b825ef827861f72d14448 100755 --- a/n2s3_examples/src/main/scala/fr/univ_lille/cristal/emeraude/n2s3/apps/ExampleMnistCompressionStatic.scala +++ b/n2s3_examples/src/main/scala/fr/univ_lille/cristal/emeraude/n2s3/apps/ExampleMnistCompressionStatic.scala @@ -64,7 +64,7 @@ object ExampleMnistCompressionStatic extends App { val formatter = new SimpleDateFormat("dd-MM-yyyy HH:mm:ss") var iteration = 0 var CropInfo = "" - var duration: Long = 0L + var globalTime: Long = 0L var simTime = "" var benchmarkMonitor: BenchmarkMonitorRef = null n2s3 = new N2S3("N2S3") @@ -151,15 +151,15 @@ object ExampleMnistCompressionStatic extends App { println("Start Training ... " + "[" + iteration + "]") if (iteration == 1 && log) { - logger = new SimMongoLog(n2s3, listOfConnexions, SimName.split("-")(0), true, true, true, true, "MNIST", SimTime,SynapseIndex) + logger = new SimMongoLog(n2s3, listOfConnexions, SimName.split("-")(0), true, true, true, true, "MNIST", SimTime,SynapseIndex, globalTime) } - duration = System.currentTimeMillis() + globalTime = System.currentTimeMillis() simTime = "Train " + iteration n2s3.runAndWait() - println(System.currentTimeMillis() - duration) - simTime = simTime + " | " + (System.currentTimeMillis() - duration) + "\n" + println(System.currentTimeMillis() - globalTime) + simTime = simTime + " | " + (System.currentTimeMillis() - globalTime) + "\n" if (iteration == globalIteration && log) { logger.storeSimInfoAndDestroy() @@ -184,12 +184,12 @@ object ExampleMnistCompressionStatic extends App { // benchmarkMonitor = n2s3.createBenchmarkMonitor(unsupervisedLayer) - // duration = System.currentTimeMillis() - // simTime = simTime + "Test " + iteration + "\n" + duration + // globalTime = System.currentTimeMillis() + // simTime = simTime + "Test " + iteration + "\n" + globalTime // n2s3.runAndWait() - // simTime = simTime + " | " + (System.currentTimeMillis() - duration) + "\n" + // simTime = simTime + " | " + (System.currentTimeMillis() - globalTime) + "\n" // benchmarkMonitor.exportToHtmlView(folderName + "/" + "test " + SimName + " [" + iteration + "]" + ".html") // benchmarkMonitor.saveCrops(folderName + "/" + "Sim " + SimName + " info a:" + alpha + " no b:" + beta, simTime, " Ratio " + Ratio) @@ -203,11 +203,11 @@ object ExampleMnistCompressionStatic extends App { println("Start Testing cropped " + "[" + iteration + "]" + " with " + Ratio) unsupervisedLayer.fixNeurons() benchmarkMonitor = n2s3.createBenchmarkMonitor(unsupervisedLayer) - duration = System.currentTimeMillis() + globalTime = System.currentTimeMillis() simTime = simTime + "Test cropped " + iteration n2s3.runAndWait() - println(System.currentTimeMillis() - duration) - simTime = simTime + " | " + (System.currentTimeMillis() - duration) + "\n" + println(System.currentTimeMillis() - globalTime) + simTime = simTime + " | " + (System.currentTimeMillis() - globalTime) + "\n" saveNeurones(unsupervisedLayer, "cropped " + "[" + iteration + "]" + " with " + Ratio) NetworkSaving.save(n2s3, croppedCnx, SynapseIndex, folderName + "/" + SimName + " Arch " + iteration + " cropped") benchmarkMonitor.exportToHtmlView(folderName + "/" + "test cropped " + SimName + " [" + iteration + "]" + ".html") 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 8e0a627a58441a315f26a46283b90a356783ea5b..401ceb9af560a0287bf21ac1b002070811b29344 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 @@ -69,7 +69,7 @@ object ExampleMnistPrune1Epoch extends App { val formatter = new SimpleDateFormat("dd-MM-yyyy HH:mm:ss") var iteration = 0 var CropInfo = "" - var duration: Long = 0L + var globalTime: Long = 0L var Totalduration: Long = 0L var simTime = "" var benchmarkMonitor: BenchmarkMonitorRef = null @@ -148,6 +148,8 @@ object ExampleMnistPrune1Epoch extends App { simTime = "" Totalduration = System.currentTimeMillis() + globalTime = System.currentTimeMillis() + while (iteration <= globalIteration) { unsupervisedLayer.unfixNeurons() @@ -157,14 +159,14 @@ object ExampleMnistPrune1Epoch extends App { stream.goto() println("Start Training ... " + "[" + iteration + "]") + if (iteration == 1 && log) { - logger = new SimMongoLog(n2s3, listOfConnexions, SimName.split("-")(0), true, true, true, true, "MNIST", SimTime,SynapseIndex) + logger = new SimMongoLog(n2s3, listOfConnexions, SimName.split("-")(0), true, true, true, true, "MNIST", SimTime,SynapseIndex,globalTime) } - duration = System.currentTimeMillis() simTime = simTime + "Train " + iteration n2s3.runAndWait() - simTime = simTime + " | " + (System.currentTimeMillis() - duration) + "\n" + simTime = simTime + " | " + (System.currentTimeMillis() - globalTime) + "\n" if (iteration == globalIteration && log) { logger.storeSimInfoAndDestroy() @@ -188,12 +190,12 @@ object ExampleMnistPrune1Epoch extends App { benchmarkMonitor = n2s3.createBenchmarkMonitor(unsupervisedLayer) - duration = System.currentTimeMillis() - simTime = simTime + "Test " + iteration + "\n" + duration + globalTime = System.currentTimeMillis() + simTime = simTime + "Test " + iteration + "\n" + globalTime n2s3.runAndWait() - simTime = simTime + " | " + (System.currentTimeMillis() - duration) + "\n" + simTime = simTime + " | " + (System.currentTimeMillis() - globalTime) + "\n" benchmarkMonitor.exportToHtmlView(folderName + "/" + "test " + SimName + " [" + iteration + "]" + ".html") benchmarkMonitor.saveCrops(folderName + "/" + "Sim " + SimName + " info a:" + alpha + " no b:" + beta, simTime, " Ratio " + Ratio) @@ -218,14 +220,14 @@ object ExampleMnistPrune1Epoch extends App { benchmarkMonitor = n2s3.createBenchmarkMonitor(unsupervisedLayer) - duration = System.currentTimeMillis() + globalTime = System.currentTimeMillis() simTime = simTime + "Test cropped " + iteration n2s3.runAndWait() - println(System.currentTimeMillis() - duration) + println(System.currentTimeMillis() - globalTime) - simTime = simTime + " | " + (System.currentTimeMillis() - duration) + "\n" + simTime = simTime + " | " + (System.currentTimeMillis() - globalTime) + "\n" saveNeurones(unsupervisedLayer, "cropped " + "[" + iteration + "]" + " with " + Ratio) NetworkSaving.save(n2s3, croppedCnx, SynapseIndex, folderName + "/" + SimName + " Arch " + iteration + " cropped") diff --git a/n2s3_examples/src/main/scala/fr/univ_lille/cristal/emeraude/n2s3/apps/ExampleMnistPrune1EpochMul.scala b/n2s3_examples/src/main/scala/fr/univ_lille/cristal/emeraude/n2s3/apps/ExampleMnistPrune1EpochMul.scala index 78a5d81f281d610e223b1c6a8a0619b3f788cb44..8b7cc4ac558708499078af5e1cf7b540eca33743 100755 --- a/n2s3_examples/src/main/scala/fr/univ_lille/cristal/emeraude/n2s3/apps/ExampleMnistPrune1EpochMul.scala +++ b/n2s3_examples/src/main/scala/fr/univ_lille/cristal/emeraude/n2s3/apps/ExampleMnistPrune1EpochMul.scala @@ -69,7 +69,7 @@ object ExampleMnistPrune1EpochMul extends App { val formatter = new SimpleDateFormat("dd-MM-yyyy HH:mm:ss") var iteration = 0 var CropInfo = "" - var duration: Long = 0L + var globalTime: Long = 0L var simTime = "" var benchmarkMonitor: BenchmarkMonitorRef = null n2s3 = new N2S3("N2S3") @@ -163,15 +163,16 @@ object ExampleMnistPrune1EpochMul extends App { stream.goto() println("Start Training ... " + "[" + hiddenLayer.identifier + "]") + globalTime = System.currentTimeMillis() if (iteration == 1 && log) { - // logger = new SimMongoLog(n2s3, listOfConnexions, SimName.split("-")(0), true, true, true, true, "MNIST", SimTime) + // logger = new SimMongoLog(n2s3, listOfConnexions, SimName.split("-")(0), true, true, true, true, "MNIST", SimTime,globalTime) } - duration = System.currentTimeMillis() + simTime = "Train " + hiddenLayer.identifier n2s3.runAndWait() - println(System.currentTimeMillis() - duration) - simTime = simTime + " | " + (System.currentTimeMillis() - duration) + "\n" + println(System.currentTimeMillis() - globalTime) + simTime = simTime + " | " + (System.currentTimeMillis() - globalTime) + "\n" if (iteration == globalIteration && log) { // logger.storeSimInfoAndDestroy() @@ -207,14 +208,13 @@ object ExampleMnistPrune1EpochMul extends App { }} if (iteration == 1 && log) { - logger = new SimMongoLog(n2s3, listOfConnexions2, SimName.split("-")(0), true, true, true, true, "MNIST", SimTime,SynapseIndex) + logger = new SimMongoLog(n2s3, listOfConnexions2, SimName.split("-")(0), true, true, true, true, "MNIST", SimTime,SynapseIndex,globalTime) } - duration = System.currentTimeMillis() simTime = "Train " + unsupervisedLayer.identifier n2s3.runAndWait() - println(System.currentTimeMillis() - duration) - simTime = simTime + " | " + (System.currentTimeMillis() - duration) + "\n" + println(System.currentTimeMillis() - globalTime) + simTime = simTime + " | " + (System.currentTimeMillis() - globalTime) + "\n" if (iteration == globalIteration && log) { logger.storeSimInfoAndDestroy() @@ -248,14 +248,14 @@ object ExampleMnistPrune1EpochMul extends App { benchmarkMonitor = n2s3.createBenchmarkMonitor(unsupervisedLayer) - duration = System.currentTimeMillis() + globalTime = System.currentTimeMillis() simTime = simTime + "Test cropped " + iteration n2s3.runAndWait() - println(System.currentTimeMillis() - duration) + println(System.currentTimeMillis() - globalTime) - simTime = simTime + " | " + (System.currentTimeMillis() - duration) + "\n" + simTime = simTime + " | " + (System.currentTimeMillis() - globalTime) + "\n" benchmarkMonitor.exportToHtmlView(folderName + "/" + "test " + SimName + " [" + iteration + "]" + ".html")