Skip to content
Snippets Groups Projects
Commit 572c82a0 authored by Elbez Hammouda's avatar Elbez Hammouda
Browse files

updated example class

parent a7a2b805
Branches
No related tags found
No related merge requests found
...@@ -50,17 +50,17 @@ object ExampleMnistPrune1Epoch extends App { ...@@ -50,17 +50,17 @@ object ExampleMnistPrune1Epoch extends App {
var NeuroneLabels = List[(Int, String)]() var NeuroneLabels = List[(Int, String)]()
var logger: SimMongoLog = null var logger: SimMongoLog = null
var log = false var log = false
var prune = false var prune = true
var globalIteration = 6 var globalIteration = 6
var sizeChunk = 10000 var sizeChunk = 10000
var networksizes = Array(10,20,50,100,500)
for(x <- 1 to 1) { for(x <- 4 to 4) {
implicit val timeout = Config.longTimeout implicit val timeout = Config.longTimeout
alpha = ArrAlpha((x - 1) / 5) alpha = ArrAlpha((x - 1) / 5)
beta = ArrBeta((x - 1) % 5) beta = ArrBeta((x - 1) % 5)
alpha = 0.05F alpha = 0.05F
beta = 0.1F beta = 0.1F
SimName = "400N" + "-" + x SimName = networksizes(x - 1)+"N" + "-" + x
println("a:" + alpha + " b:" + beta) println("a:" + alpha + " b:" + beta)
QBGParameters.alf_m = 0.005f QBGParameters.alf_m = 0.005f
QBGParameters.alf_p = 0.01f QBGParameters.alf_p = 0.01f
...@@ -70,6 +70,7 @@ object ExampleMnistPrune1Epoch extends App { ...@@ -70,6 +70,7 @@ object ExampleMnistPrune1Epoch extends App {
var iteration = 0 var iteration = 0
var CropInfo = "" var CropInfo = ""
var duration: Long = 0L var duration: Long = 0L
var Totalduration: Long = 0L
var simTime = "" var simTime = ""
var benchmarkMonitor: BenchmarkMonitorRef = null var benchmarkMonitor: BenchmarkMonitorRef = null
n2s3 = new N2S3("N2S3") n2s3 = new N2S3("N2S3")
...@@ -96,7 +97,7 @@ object ExampleMnistPrune1Epoch extends App { ...@@ -96,7 +97,7 @@ object ExampleMnistPrune1Epoch extends App {
val unsupervisedLayer = n2s3.createNeuronGroup() val unsupervisedLayer = n2s3.createNeuronGroup()
.setIdentifier("OutLayer") .setIdentifier("OutLayer")
.setNumberOfNeurons(400) .setNumberOfNeurons(networksizes(x - 1))
.setNeuronModel(LIF, Seq( .setNeuronModel(LIF, Seq(
(MembranePotentialThreshold, 35 millivolts))) (MembranePotentialThreshold, 35 millivolts)))
...@@ -145,9 +146,10 @@ object ExampleMnistPrune1Epoch extends App { ...@@ -145,9 +146,10 @@ object ExampleMnistPrune1Epoch extends App {
val dataTestFile = N2S3ResourceManager.getByName("mnist-test-images").getAbsolutePath val dataTestFile = N2S3ResourceManager.getByName("mnist-test-images").getAbsolutePath
val labelTestFile = N2S3ResourceManager.getByName("mnist-test-labels").getAbsolutePath val labelTestFile = N2S3ResourceManager.getByName("mnist-test-labels").getAbsolutePath
while (iteration <= globalIteration) {
simTime = "" simTime = ""
Totalduration = System.currentTimeMillis()
while (iteration <= globalIteration) {
unsupervisedLayer.unfixNeurons() unsupervisedLayer.unfixNeurons()
n2s3.first = false n2s3.first = false
stream = InputMnist.DataParts(dataFile, labelFile, sizeChunk*(iteration-1), sizeChunk) stream = InputMnist.DataParts(dataFile, labelFile, sizeChunk*(iteration-1), sizeChunk)
...@@ -159,22 +161,21 @@ object ExampleMnistPrune1Epoch extends App { ...@@ -159,22 +161,21 @@ object ExampleMnistPrune1Epoch extends App {
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)
} }
duration = System.currentTimeMillis() duration = System.currentTimeMillis()
simTime = "Train " + iteration simTime = simTime + "Train " + iteration
n2s3.runAndWait() n2s3.runAndWait()
println(System.currentTimeMillis() - duration)
simTime = simTime + " | " + (System.currentTimeMillis() - duration) + "\n" simTime = simTime + " | " + (System.currentTimeMillis() - duration) + "\n"
if (iteration == globalIteration && log) { if (iteration == globalIteration && log) {
logger.storeSimInfoAndDestroy() logger.storeSimInfoAndDestroy()
} }
println("saving : " + System.currentTimeMillis()) //println("saving : " + System.currentTimeMillis())
NetworkSaving.save(n2s3, croppedCnx, SynapseIndex, folderName + "/" + SimName + " Arch " + iteration) //NetworkSaving.save(n2s3, croppedCnx, SynapseIndex, folderName + "/" + SimName + " Arch " + iteration)
println("end : " + System.currentTimeMillis()) //println("end : " + System.currentTimeMillis())
println("saving cropped : " + System.currentTimeMillis()) //println("saving cropped : " + System.currentTimeMillis())
saveNeurones(unsupervisedLayer, "[" + iteration + "]") //saveNeurones(unsupervisedLayer, "[" + iteration + "]")
println("end : " + System.currentTimeMillis()) //println("end : " + System.currentTimeMillis())
/* /*
inputStream.append(InputMnist.DataFrom(dataTestFile, labelTestFile)) inputStream.append(InputMnist.DataFrom(dataTestFile, labelTestFile))
...@@ -204,6 +205,7 @@ object ExampleMnistPrune1Epoch extends App { ...@@ -204,6 +205,7 @@ object ExampleMnistPrune1Epoch extends App {
println("cropping : " + System.currentTimeMillis()) println("cropping : " + System.currentTimeMillis())
CropInfo = cropNetwork(inputLayer, Ratio) CropInfo = cropNetwork(inputLayer, Ratio)
println("end : " + System.currentTimeMillis()) println("end : " + System.currentTimeMillis())
simTime = simTime + "cropped " + "[" + iteration + "]" + " with " + Ratio + "\n"
// cropInput(n2s3.inputLayerRef.get, Ratio) // cropInput(n2s3.inputLayerRef.get, Ratio)
} }
...@@ -229,7 +231,7 @@ object ExampleMnistPrune1Epoch extends App { ...@@ -229,7 +231,7 @@ object ExampleMnistPrune1Epoch extends App {
NetworkSaving.save(n2s3, croppedCnx, SynapseIndex, folderName + "/" + SimName + " Arch " + iteration + " cropped") 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")
simTime = simTime + "Total time: " + (System.currentTimeMillis() - Totalduration) + "\n"
benchmarkMonitor.saveCrops(folderName + "/" + "Sim " + SimName + " info a:" + alpha + " b:" + beta, simTime, CropInfo + " Ratio " + Ratio) benchmarkMonitor.saveCrops(folderName + "/" + "Sim " + SimName + " info a:" + alpha + " b:" + beta, simTime, CropInfo + " Ratio " + Ratio)
} }
if (iteration == globalIteration && log) { if (iteration == globalIteration && log) {
...@@ -238,7 +240,9 @@ object ExampleMnistPrune1Epoch extends App { ...@@ -238,7 +240,9 @@ object ExampleMnistPrune1Epoch extends App {
iteration += 1 iteration += 1
} }
} }
//logger.destroy() //logger.destroy()
n2s3.destroy() n2s3.destroy()
sys.exit(0) sys.exit(0)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment