Skip to content
Snippets Groups Projects
Commit 2e5a3ca1 authored by Hammouda Elbez's avatar Hammouda Elbez :computer:
Browse files

Prints moved to debug mode

parent 76403575
No related branches found
No related tags found
1 merge request!26Custom 2d view
......@@ -118,21 +118,24 @@ class Global_Var():
if ('labels' in self.db.list_collection_names()):
col = pymongo.collection.Collection(self.db, 'labels')
col.create_index([("T", 1)])
print("Labels index done")
if self.config.DEBUG:
print("Labels index done")
if ('spikes' in self.db.list_collection_names()):
col = pymongo.collection.Collection(self.db, 'spikes')
col.create_index([("T", 1)])
col.create_index([("i.L", 1)])
col.create_index([("i.N", 1)])
print("Spikes index done")
if self.config.DEBUG:
print("Spikes index done")
if ('potential' in self.db.list_collection_names()):
col = pymongo.collection.Collection(self.db, 'potential')
col.create_index([("T", 1)])
col.create_index([("L", 1)])
col.create_index([("N", 1)])
print("Potential index done")
if self.config.DEBUG:
print("Potential index done")
if ('synapseWeight' in self.db.list_collection_names()):
col = pymongo.collection.Collection(self.db, 'synapseWeight')
......@@ -140,7 +143,8 @@ class Global_Var():
col.create_index([("C", 1)])
col.create_index([("L", 1)])
col.create_index([("To", 1)])
print("Synapses index done")
if self.config.DEBUG:
print("Synapses index done")
def getLabelTime(self, step, value):
""" Return a string that represent time .
......
......@@ -609,9 +609,9 @@ class callbacks(callbacksOp):
matrix[layer] = []
indices[layer] = []
heatmaps = [{"data":[go.Heatmap(z = matrix[layer], colorscale= 'Reds', customdata = indices[layer], hovertemplate=('Neuron: %{customdata} <br>Spikes: %{z} <extra></extra>'))],"layout":{"xaxis":dict(showgrid = False, zeroline = False),"yaxis":dict(autorange = 'reversed',scaleanchor = 'x',showgrid = False, zeroline = False),"margin":{'l': 0, 'r': 0, 't': 5, 'b': 0},"uirevision":'no reset of zoom', "hoverlabel_align": 'right'}} for layer in super.AccumulatedSpikes2D]
heatmaps = [{"data":[go.Heatmap(z = matrix[layer], colorscale= 'Reds', customdata = indices[layer], hovertemplate=('Neuron: %{customdata} <br>Spikes: %{z} <extra></extra>'),xgap=4,ygap=4)],"layout":{"xaxis":dict(showgrid = False, zeroline = False),"yaxis":dict(autorange = 'reversed',scaleanchor = 'x',showgrid = False, zeroline = False),"margin":{'l': 0, 'r': 0, 't': 5, 'b': 0},"uirevision":'no reset of zoom', "hoverlabel_align": 'right'}} for layer in super.AccumulatedSpikes2D]
SpikesActivityPerInput = [{"data":[go.Heatmap(z=super.SpikesActivityPerInput[layer], colorscale= 'Reds',hovertemplate=('Class: %{x} <br>Neuron: %{y} <br>Spikes: %{z} <extra></extra>'))],"layout":{"xaxis":dict(title="Class",tickmode="array",tickvals=[i for i in range(g.nbrClasses+1)]),"yaxis":dict(title="Neuron"),"margin":{'r': 0,'t': 0},"uirevision":'no reset of zoom'}} for layer in super.SpikesActivityPerInput]
SpikesActivityPerInput = [{"data":[go.Heatmap(z=super.SpikesActivityPerInput[layer], colorscale= 'Reds',hovertemplate=('Class: %{x} <br>Neuron: %{y} <br>Spikes: %{z} <extra></extra>'),xgap=4,ygap=4)],"layout":{"xaxis":dict(title="Class",tickmode="array",zeroline = False,tickvals=[i for i in range(g.nbrClasses+1)]),"yaxis":dict(title="Neuron",zeroline = False),"margin":{'r': 0,'t': 0},"uirevision":'no reset of zoom'}} for layer in super.SpikesActivityPerInput]
return [elements,[],heatmaps,SpikesActivityPerInput]
else:
......@@ -626,9 +626,9 @@ class callbacks(callbacksOp):
matrix[layer] = []
indices[layer] = []
heatmaps = [{"data":[go.Heatmap(z = matrix[layer], colorscale= 'Reds', customdata = indices[layer], hovertemplate=('Neuron: %{customdata} <br>Spikes: %{z} <extra></extra>'))],"layout":{"xaxis":dict(showgrid = False, zeroline = False),"yaxis":dict(autorange = 'reversed',scaleanchor = 'x',showgrid = False, zeroline = False),"margin":{'l': 0, 'r': 0, 't': 5, 'b': 0},"uirevision":'no reset of zoom', "hoverlabel_align": 'right'}} for layer in super.AccumulatedSpikes2D]
heatmaps = [{"data":[go.Heatmap(z = matrix[layer], colorscale= 'Reds', customdata = indices[layer], hovertemplate=('Neuron: %{customdata} <br>Spikes: %{z} <extra></extra>'),xgap=4,ygap=4)],"layout":{"xaxis":dict(showgrid = False, zeroline = False),"yaxis":dict(autorange = 'reversed',scaleanchor = 'x',showgrid = False, zeroline = False),"margin":{'l': 0, 'r': 0, 't': 5, 'b': 0},"uirevision":'no reset of zoom', "hoverlabel_align": 'right'}} for layer in super.AccumulatedSpikes2D]
SpikesActivityPerInput = [{"data":[go.Heatmap(z=super.SpikesActivityPerInput[layer], colorscale= 'Reds',hovertemplate=('Class: %{x} <br>Neuron: %{y} <br>Spikes: %{z} <extra></extra>'))],"layout":{"xaxis":dict(title="Class",tickmode="array",tickvals=[i for i in range(g.nbrClasses+1)]),"yaxis":dict(title="Neuron"),"margin":{'r': 0,'t': 0},"uirevision":'no reset of zoom'}} for layer in super.SpikesActivityPerInput]
SpikesActivityPerInput = [{"data":[go.Heatmap(z=super.SpikesActivityPerInput[layer], colorscale= 'Reds',hovertemplate=('Class: %{x} <br>Neuron: %{y} <br>Spikes: %{z} <extra></extra>'),xgap=4,ygap=4)],"layout":{"xaxis":dict(title="Class",tickmode="array",zeroline = False,tickvals=[i for i in range(g.nbrClasses+1)]),"yaxis":dict(title="Neuron",zeroline = False),"margin":{'r': 0,'t': 0},"uirevision":'no reset of zoom'}} for layer in super.SpikesActivityPerInput]
return [elements,f"Neuron {mouseOverNodeData['label']} : {mouseOverNodeData['spikes']}" if 'spikes' in mouseOverNodeData else "", heatmaps,SpikesActivityPerInput]
except Exception:
print("OnHover:"+traceback.format_exc())
......
......@@ -93,7 +93,8 @@ class spark(sparkOp):
pass
# ------------------------------------------------------------
print("done ", self.MODULE_NAME)
if self.g.config.DEBUG:
print("done ", self.MODULE_NAME)
except Exception:
print("GlobalSpark:" + traceback.format_exc())
......
......@@ -57,7 +57,8 @@ class layout(layoutOp):
"""
try:
self.clearData([])
print("neuron-vis")
if self.g.config.DEBUG:
print("neuron-vis")
self.SpikePerNeuron = self.getSpikePerNeuron(self.g)
layer = dbc.Card(
dbc.CardBody(
......@@ -181,11 +182,11 @@ class layout(layoutOp):
'layout': {'margin': {'l': 0, 'r': 0, 't': 30, 'b': 0}}}
else:
data = self.SpikePerNeuron
print(data)
data = [d for d, l in product(data, g.finalLabels) if (
int(l["N"]) == d['i']['N'] and int(l["Label"]) == filteredClass["z"])]
xx = [N["i"]["N"] for N in data]
yy = [(count["count"]) for count in data]
yy = [count["count"] for count in data]
graph = {'data': [go.Bar(
x=[x for x in range(len(xx))],
......
......@@ -53,7 +53,8 @@ class spark(sparkOp):
if(not self.DOCUMENT_NAME in self.g.db.list_collection_names()):
print(self.DOCUMENT_NAME, "not found")
self.g.modules = [module for module in self.g.modules if module != self.MODULE_NAME]
print("done ", self.MODULE_NAME)
if self.g.config.DEBUG:
print("done ", self.MODULE_NAME)
except Exception:
print("Error:" + traceback.format_exc())
......
......@@ -61,8 +61,9 @@ class spark(sparkOp):
col = pymongo.collection.Collection(self.g.db, 'synapseWeightFinal')
globalSynapseWeights = pd.DataFrame(list(col.aggregate([{"$group": {"_id":None, "x":{"$max":"$_id.index.x"}, "y":{"$max":"$_id.index.y"}}}])))
self.g.NeuronsSize = {"x":globalSynapseWeights["x"].max(),"y":globalSynapseWeights["y"].max()}
print("done", self.MODULE_NAME)
if self.g.config.DEBUG:
print("done", self.MODULE_NAME)
except Exception:
print("Error:" + traceback.format_exc())
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment