Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N2S3
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Hammouda Elbez
N2S3
Commits
9962f7f4
Commit
9962f7f4
authored
4 years ago
by
Elbez Hammouda
Browse files
Options
Downloads
Patches
Plain Diff
MongoDB class updated
parent
797f52ea
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
n2s3/src/main/scala/fr/univ_lille/cristal/emeraude/n2s3/features/logging/SimMongoLog.scala
+8
-45
8 additions, 45 deletions
.../cristal/emeraude/n2s3/features/logging/SimMongoLog.scala
with
8 additions
and
45 deletions
n2s3/src/main/scala/fr/univ_lille/cristal/emeraude/n2s3/features/logging/SimMongoLog.scala
+
8
−
45
View file @
9962f7f4
...
...
@@ -18,7 +18,7 @@ import scala.collection.immutable
/**
* Hammouda Elbez
*
*
Fichier
respons
a
ble
sur la collection des informations sur la simulation et le stockage dans la base de données
Mongo
*
Class
respons
i
ble
for storing data in
Mongo
DB
*
*/
...
...
@@ -109,14 +109,7 @@ class SimMongoLog(n2s3 : N2S3,list : IndexedSeq[IndexedSeq[IndexedSeq[Connection
"QtInput"
->
benchmark
.
getResult
.
quietInputCount
,
"NLabel"
->
NeuronLabel
)).
subscribe
(
observer
)
// adding Timestamps index to collections
// PotentialCollection.createIndex(Indexes.ascending("T"))
// SpikesCollection.createIndex(Indexes.ascending("T"))
// SynapseWeightCollection.createIndex(Indexes.ascending("T"))
mongoClient
.
close
()
// val restartMongo = "service mongod restart" !
}
/**
...
...
@@ -128,35 +121,19 @@ class SimMongoLog(n2s3 : N2S3,list : IndexedSeq[IndexedSeq[IndexedSeq[Connection
InfoCollection
=
database
.
getCollection
(
"info"
)
InfoCollection
.
deleteMany
(
new
BasicDBObject
())
PotentialCollection
=
database
.
getCollection
(
"potential"
)
//PotentialCollection.deleteMany(new BasicDBObject())
SpikesCollection
=
database
.
getCollection
(
"spikes"
)
//SpikesCollection.deleteMany(new BasicDBObject())
LabelCollection
=
database
.
getCollection
(
"labels"
)
//LabelCollection.deleteMany(new BasicDBObject())
SynapseWeightCollection
=
database
.
getCollection
(
"synapseWeight"
)
//SynapseWeightCollection.deleteMany(new BasicDBObject())
var
neuronsFireLogDocuments
:
List
[
Document
]
=
List
.
empty
var
neuronsPotentialLogDocuments
:
List
[
Document
]
=
List
.
empty
var
labelMonitoringDocuments
:
List
[
Document
]
=
List
.
empty
var
synapticWeightMonitoringDocuments
:
List
[
Document
]
=
List
.
empty
//***************************************
println
(
"Starting Log"
)
//println("Layer name : " + n2s3.layers(0).identifier)
//println("Inputs : " + n2s3.layers(0).neurons.size)
/** ******************************************************************************************************************
* Architecture Save
* *****************************************************************************************************************/
// var Neuron_id: List[Int] = List[Int]()
//ArchiCollection.insertOne(Document("n" -> name,"i" -> n2s3.layers(0).neurons.size)).subscribe(observer)
var
layerNeron
:
Map
[
String
,
Int
]
=
Map
()
n2s3
.
layers
.
foreach
(
layer
=>
{
layerNeron
+=
(
layer
.
identifier
->
layer
.
neurons
.
size
)
...
...
@@ -257,7 +234,7 @@ class NeuronsFireLog(name : String,mongoCollection: MongoCollection[Document], o
time
=
(
System
.
currentTimeMillis
()
-
globalTimestamps
)
*
1000
if
(
i
<
step
){
documents
=
documents
.::(
Document
(
"i"
->
Document
(
"L"
->
path
.
actor
.
path
.
name
.
split
(
":"
)(
0
),
"N"
->
BsonInt32
.
apply
(
Integer
.
valueOf
(
path
.
actor
.
path
.
name
.
split
(
":"
)(
1
)))),
"T"
->
time
,
"Input"
->
GlobalLogVars
.
ActualInput
))
"N"
->
BsonInt32
.
apply
(
Integer
.
valueOf
(
path
.
actor
.
path
.
name
.
split
(
":"
)(
1
)))),
"T"
->
BsonDouble
.
apply
(
BigDecimal
(
time
/
1000000
).
setScale
(
6
,
BigDecimal
.
RoundingMode
.
HALF_UP
).
toDouble
)
,
"Input"
->
GlobalLogVars
.
ActualInput
))
// ,"tt" -> BsonDouble(step*i)
i
=
i
+
1
}
else
{
...
...
@@ -292,11 +269,9 @@ class NeuronsPotentialLog(name : String,mongoCollection: MongoCollection[Documen
override
def
process
(
message
:
Message
,
sender
:
ActorRef
)
:
Unit
=
message
match
{
case
NeuronPotentialResponse
(
timestamp
,
source
,
value
)
=>
if
(((
System
.
currentTimeMillis
()
-
globalTimestamps
)
*
1000
)
-
time
>
250
){
time
=
(
System
.
currentTimeMillis
()
-
globalTimestamps
)
/
1000
documents
=
documents
.::(
Document
(
"T"
->
time
,
"L"
->
source
.
actor
.
path
.
name
.
split
(
":"
)(
0
),
"N"
->
BsonInt32
(
Integer
.
valueOf
(
source
.
actor
.
path
.
name
.
split
(
":"
)(
1
))),
"V"
->
time
=
(
System
.
currentTimeMillis
()
-
globalTimestamps
)
*
1000
documents
=
documents
.::(
Document
(
"T"
->
BsonDouble
.
apply
(
BigDecimal
(
time
/
1000000
).
setScale
(
6
,
BigDecimal
.
RoundingMode
.
HALF_UP
).
toDouble
),
"L"
->
source
.
actor
.
path
.
name
.
split
(
":"
)(
0
),
"N"
->
BsonInt32
(
Integer
.
valueOf
(
source
.
actor
.
path
.
name
.
split
(
":"
)(
1
))),
"V"
->
BsonDouble
.
apply
(
BigDecimal
(
value
).
setScale
(
6
,
BigDecimal
.
RoundingMode
.
HALF_UP
).
toDouble
)))
// "_id" -> id,
i
=
i
+
1
if
(
i
>
10000
){
...
...
@@ -316,7 +291,7 @@ class NeuronsPotentialLog(name : String,mongoCollection: MongoCollection[Documen
}
/** ******************************************************************************************************************
* Label changement Logger for
supervised learning
* Label changement Logger for
labeled datasets
* *****************************************************************************************************************/
class
LabelMonitoring
(
n2s3
:
N2S3
,
outputNeuron
:
Seq
[
NeuronGroupRef
],
mongoCollection
:
MongoCollection
[
Document
],
observer
:
Observer
[
Completed
],
globalTimestamps
:
Timestamp
)
extends
Actor
{
...
...
@@ -340,7 +315,7 @@ class LabelMonitoring(n2s3 : N2S3, outputNeuron : Seq[NeuronGroupRef],mongoColle
time
=
(
System
.
currentTimeMillis
()
-
globalTimestamps
)
/
1000
GlobalLogVars
.
ActualInput
=
label
GlobalLogVars
.
globalInput
=
GlobalLogVars
.
globalInput
+
1
documents
=
documents
.::(
Document
(
"L"
->
BsonInt32
(
Integer
.
valueOf
(
label
)),
"T"
->
time
,
"G"
->
GlobalLogVars
.
globalInput
))
documents
=
documents
.::(
Document
(
"L"
->
BsonInt32
(
Integer
.
valueOf
(
label
)),
"T"
->
BsonDouble
.
apply
(
BigDecimal
(
time
).
setScale
(
6
,
BigDecimal
.
RoundingMode
.
HALF_UP
).
toDouble
)
,
"G"
->
GlobalLogVars
.
globalInput
))
i
=
i
+
1
...
...
@@ -363,8 +338,6 @@ class SynapticWeightMonitoring(list : IndexedSeq[IndexedSeq[IndexedSeq[Connectio
override
def
deploy
(
n2s3
:
N2S3
)
:
Unit
=
{
this
.
actor
=
Some
(
n2s3
.
system
.
actorOf
(
Props
(
new
SynapticWeight
(
list
,
refreshRate
,
name
,
mongoCollection
,
observer
,
step
,
globalTimestamps
,
SynapseIndex
)),
LocalActorDeploymentStrategy
))
// this.actor = Some(n2s3.system.actorOf(Props(new ActivityStoreActor(n2s3)), LocalActorDeploymentStrategy))
}
}
...
...
@@ -385,9 +358,7 @@ class SynapticWeight(list : Seq[Seq[Seq[ConnectionPath]]], refreshRate : Int = 1
var
filteredconnectionList
:
Seq
[(
Int
,
Int
,
ConnectionPath
)]
=
Seq
.
empty
def
update
()
:
Unit
=
{
// println(synapseList)
values
=
synapseList
.
flatMap
{
case
(
neuron
,
connectionList
)
=>
// println(neuron.actor.path.name)
if
(
connectionList
.
size
==
1
)
{
Some
((
connectionList
.
head
.
_1
,
connectionList
.
head
.
_2
,
ExternalConnectionSender
.
askTo
(
connectionList
.
head
.
_3
,
GetConnectionProperty
(
SynapticWeightFloat
))
.
asInstanceOf
[
PropertyValue
[
Float
]].
value
,
neuron
))
...
...
@@ -407,8 +378,6 @@ class SynapticWeight(list : Seq[Seq[Seq[ConnectionPath]]], refreshRate : Int = 1
filteredconnectionList
.
map
{
case
(
x
,
y
,
p
)
=>
(
p
.
connectionID
,
p
.
outputNeuron
.
actor
.
path
.
name
.
split
(
":"
)(
1
).
toInt
,
values
(
p
.
connectionID
).
head
.
_3
,
p
.
outputNeuron
)}
}
}
// values.foreach( x => println(s"From : ${x._1} , To : ${x._2} , Value : ",f"${x._3}%1.6f"))
// if (i < 5) {
if
(
valuesTmp
.
isEmpty
){
valuesTmp
=
values
}
else
{
...
...
@@ -426,18 +395,14 @@ class SynapticWeight(list : Seq[Seq[Seq[ConnectionPath]]], refreshRate : Int = 1
}
})
documents
=
documents
.::(
Document
(
"T"
->
(
System
.
currentTimeMillis
()
-
globalTimestamps
)
/
1000
,
"C"
->
v
.
_1
,
"L"
->
v
.
_4
.
actor
.
path
.
name
.
split
(
":"
)(
0
),
"To"
->
v
.
_2
,
"V"
->
BsonDouble
.
apply
(
BigDecimal
(
v
.
_3
).
setScale
(
6
,
BigDecimal
.
RoundingMode
.
HALF_UP
).
toDouble
),
"index"
->
Document
(
"x"
->
y
,
"y"
->
x
)))})
documents
=
documents
.::(
Document
(
"T"
->
BsonDouble
.
apply
(
BigDecimal
(
(
System
.
currentTimeMillis
()
-
globalTimestamps
)
/
1000
).
setScale
(
6
,
BigDecimal
.
RoundingMode
.
HALF_UP
).
toDouble
)
,
"C"
->
v
.
_1
,
"L"
->
v
.
_4
.
actor
.
path
.
name
.
split
(
":"
)(
0
),
"To"
->
v
.
_2
,
"V"
->
BsonDouble
.
apply
(
BigDecimal
(
v
.
_3
).
setScale
(
6
,
BigDecimal
.
RoundingMode
.
HALF_UP
).
toDouble
),
"index"
->
Document
(
"x"
->
y
,
"y"
->
x
)))})
valuesTmp
=
values
values
=
List
.
empty
// i = i + 1
// } else {
if
(
documents
.
nonEmpty
){
mongoCollection
.
insertMany
(
documents
).
subscribe
(
observer
)
// i = 0
documents
=
List
.
empty
}
// }
}
}
...
...
@@ -466,8 +431,6 @@ class ActivityStoreActor(n2s3 : N2S3) extends NetworkActor {
var
currentTimestamp
:
Timestamp
=
-
1L
var
eventCount
:
Long
=
0
override
def
initialize
()
:
Unit
=
{
askTo
(
n2s3
.
inputLayerRef
.
get
.
getContainer
,
SubscribeSynchronized
(
SynapseWeightChange
,
ExternalSender
.
getReference
(
self
),
n2s3
.
buildProperties
.
getSynchronizerPolicy
.
getInputSynchronizer
))
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment