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

General module multilayer support finalised

parent aa9bb56d
Branches
No related tags found
1 merge request!22V0.351
...@@ -78,3 +78,7 @@ button:focus{ ...@@ -78,3 +78,7 @@ button:focus{
color: rgb(68, 71, 99); color: rgb(68, 71, 99);
background-color: rgba(68, 71, 99, 0.116); background-color: rgba(68, 71, 99, 0.116);
} }
.Select-control{
width: 100% !important;
}
\ No newline at end of file
...@@ -63,6 +63,7 @@ class callbacks(): ...@@ -63,6 +63,7 @@ class callbacks():
graphs = {l:[] for l in generalLayerFilter} graphs = {l:[] for l in generalLayerFilter}
annotations = [] annotations = []
for layer in generalLayerFilter: for layer in generalLayerFilter:
i = 0 i = 0
for f in generalGraphFilter: for f in generalGraphFilter:
...@@ -70,7 +71,7 @@ class callbacks(): ...@@ -70,7 +71,7 @@ class callbacks():
if(layer not in super.SpikeGraphY): if(layer not in super.SpikeGraphY):
super.SpikeGraphY[layer] = deque(maxlen=100) super.SpikeGraphY[layer] = deque(maxlen=100)
super.MaxSpike[layer] = 0 super.MaxSpike[layer] = 0
if data != None and layer in data[i]: if data[i] != None and layer in data[i]:
super.SpikeGraphY[layer].append(data[i][layer]["spikes"]) super.SpikeGraphY[layer].append(data[i][layer]["spikes"])
else: else:
super.SpikeGraphY[layer].append(0) super.SpikeGraphY[layer].append(0)
...@@ -86,7 +87,7 @@ class callbacks(): ...@@ -86,7 +87,7 @@ class callbacks():
fill='tozeroy' if len( fill='tozeroy' if len(
generalGraphFilter) == 1 else 'none', generalGraphFilter) == 1 else 'none',
line=dict(color="rgb(31, 119, 180)"), line=dict(color="rgb(31, 119, 180)"),
name='Spikes', name='Spikes ['+layer+']',
mode='lines+markers', mode='lines+markers',
text=list(super.xAxisLabel), text=list(super.xAxisLabel),
customdata=list(super.SpikeGraphY[layer]), customdata=list(super.SpikeGraphY[layer]),
...@@ -97,7 +98,7 @@ class callbacks(): ...@@ -97,7 +98,7 @@ class callbacks():
if(layer not in super.SynapseGraphY): if(layer not in super.SynapseGraphY):
super.SynapseGraphY[layer] = deque(maxlen=100) super.SynapseGraphY[layer] = deque(maxlen=100)
super.MaxSynapse[layer] = 0 super.MaxSynapse[layer] = 0
if data != None and layer in data[i]: if data[i] != None and layer in data[i]:
super.SynapseGraphY[layer].append(data[i][layer]["synapseUpdate"]) super.SynapseGraphY[layer].append(data[i][layer]["synapseUpdate"])
else: else:
super.SynapseGraphY[layer].append(0) super.SynapseGraphY[layer].append(0)
...@@ -111,7 +112,7 @@ class callbacks(): ...@@ -111,7 +112,7 @@ class callbacks():
fill='tozeroy' if len( fill='tozeroy' if len(
generalGraphFilter) == 1 else 'none', generalGraphFilter) == 1 else 'none',
line=dict(color="rgb(255, 127, 14)"), line=dict(color="rgb(255, 127, 14)"),
name='Synapses update', name='Synapses activity ['+layer+']',
mode='lines+markers', mode='lines+markers',
text=list(super.xAxisLabel), text=list(super.xAxisLabel),
customdata=list(super.SynapseGraphY[layer]), customdata=list(super.SynapseGraphY[layer]),
...@@ -120,7 +121,7 @@ class callbacks(): ...@@ -120,7 +121,7 @@ class callbacks():
if(layer not in super.PotentialGraphY): if(layer not in super.PotentialGraphY):
super.PotentialGraphY[layer] = deque(maxlen=100) super.PotentialGraphY[layer] = deque(maxlen=100)
super.MaxPotential[layer] = 0 super.MaxPotential[layer] = 0
if data != None and layer in data[i]: if data[i] != None and layer in data[i]:
super.PotentialGraphY[layer].append(data[i][layer]["potential"]) super.PotentialGraphY[layer].append(data[i][layer]["potential"])
else: else:
super.PotentialGraphY[layer].append(0) super.PotentialGraphY[layer].append(0)
...@@ -135,13 +136,15 @@ class callbacks(): ...@@ -135,13 +136,15 @@ class callbacks():
fill='tozeroy' if len( fill='tozeroy' if len(
generalGraphFilter) == 1 else 'none', generalGraphFilter) == 1 else 'none',
line=dict(color="rgb(44, 160, 44)"), line=dict(color="rgb(44, 160, 44)"),
name="Neuron's potential update", name='Neuron\'s potential ['+layer+']',
mode='lines+markers', mode='lines+markers',
text=list(super.xAxisLabel), text=list(super.xAxisLabel),
customdata=list(super.PotentialGraphY[layer]), customdata=list(super.PotentialGraphY[layer]),
hovertemplate="%{text} <br> <b>%{customdata}</b> <br> <b>Max</b> "+str(super.MaxPotential[layer]))) hovertemplate="%{text} <br> <b>%{customdata}</b> <br> <b>Max</b> "+str(super.MaxPotential[layer])))
i += 1 i += 1
if(len(graphs) != 0):
if(g.Labels != None): if(g.Labels != None):
if(data[-1] != None): if(data[-1] != None):
...@@ -171,23 +174,6 @@ class callbacks(): ...@@ -171,23 +174,6 @@ class callbacks():
fig.add_trace( fig.add_trace(
graph, row=3, col=1) graph, row=3, col=1)
fig['layout'].update(
xaxis2=dict(
title='Step',
autorange=True,
range=[min(super.InfoGraphX) if super.InfoGraphX else 0, max(
super.InfoGraphX) if super.InfoGraphX else 0],
#rangeslider={'visible': True,'autorange': True},
# showticklabels=False,
tickvals=list(super.InfoGraphX),
),
yaxis1=dict(
range=[0, 105]
),
showlegend=True,
uirevision='no reset of zoom',
margin={'l': 0, 'r': 0, 't': 30, 'b': 25},
annotations=annotations)
else: else:
fig = make_subplots( fig = make_subplots(
rows=len(graphs), cols=1, shared_xaxes=True,vertical_spacing=0.05) rows=len(graphs), cols=1, shared_xaxes=True,vertical_spacing=0.05)
...@@ -199,21 +185,25 @@ class callbacks(): ...@@ -199,21 +185,25 @@ class callbacks():
graph, row=l, col=1) graph, row=l, col=1)
l +=1 l +=1
fig.update_xaxes(title_text="Step", row=len(graphs), col=1)
fig['layout'].update( fig['layout'].update(
# TODO: change axis when there is no Loss
xaxis=dict(
title='Step',
autorange=True,
range=[min(super.InfoGraphX) if super.InfoGraphX else 0, max(
super.InfoGraphX) if super.InfoGraphX else 0],
#rangeslider={'visible': True,'autorange': True},
# showticklabels=False,
tickvals=list(super.InfoGraphX)),
yaxis=dict(range=[0, 105]), yaxis=dict(range=[0, 105]),
showlegend=True, showlegend=True,
uirevision='no reset of zoom', uirevision='no reset of zoom',
margin={'l': 0, 'r': 0, 't': 30, 'b': 25}, margin={'l': 0, 'r': 0, 't': 30, 'b': 25},
annotations=annotations) annotations=annotations)
else:
fig = make_subplots(rows=1, cols=1, shared_xaxes=True, vertical_spacing=0.05, specs=[[{'rowspan': 1}]])
fig.add_trace(
go.Scatter(x=list(), y=list(), mode='lines',
line={"color": "#dc3545",
"dash": "dot",
"width": 2},
),row=1, col=1)
return fig return fig
except Exception as e: except Exception as e:
......
...@@ -68,6 +68,7 @@ class layout(): ...@@ -68,6 +68,7 @@ class layout():
self.SpikeGraphY.clear() self.SpikeGraphY.clear()
self.LossGraphY.clear() self.LossGraphY.clear()
self.SynapseGraphY.clear() self.SynapseGraphY.clear()
self.PotentialGraphY.clear()
self.xAxisLabel.clear() self.xAxisLabel.clear()
self.Label.clear() self.Label.clear()
self.MaxPotential = dict() self.MaxPotential = dict()
...@@ -133,18 +134,18 @@ class layout(): ...@@ -133,18 +134,18 @@ class layout():
# Graphs filter # Graphs filter
dcc.Dropdown( dcc.Dropdown(
id='GeneralGraphFilter', id='GeneralGraphFilter',
options=[{'label': "Spikes", 'value': "Spikes"}, {'label': "Synapses update", 'value': "Synapses"}, { options=[{'label': "Spikes", 'value': "Spikes"}, {'label': "Synapses activity", 'value': "Synapses"}, {
'label': "Neurons potential update", 'value': "Potentials"}], 'label': "Neurons potential", 'value': "Potentials"}],
value=['Spikes'], value=['Spikes'],
multi=True, multi=True,
style={'width': '50%', "marginLeft": "10px", "textAlign": "start"}), style={"minWidth":"10%","marginLeft": "10px", "textAlign": "start"}),
# Layers filter # Layers filter
dcc.Dropdown( dcc.Dropdown(
id='GeneralLayerFilter', id='GeneralLayerFilter',
options=[{'label': str(i), 'value': str(i)} for i in (i for i in g.Layer_Neuron if i != "Input")], options=[{'label': str(i), 'value': str(i)} for i in (i for i in g.Layer_Neuron if i != "Input")],
value=[str(i) for i in (i for i in g.Layer_Neuron if i != "Input")], value=[str(i) for i in (i for i in g.Layer_Neuron if i != "Input")],
multi=True, multi=True,
style={'width': '50%', "marginLeft": "5px", "textAlign": "start"})], className="row", style={"paddingLeft": "20px"}) style={"minWidth":"10%","marginLeft": "15px", "textAlign": "start"})], className="row", style={"paddingLeft": "20px",'width': '100%'})
], className="col-12") ], className="col-12")
], className="row"), ], className="row"),
html.Div([dcc.Graph(id='general-graph', animate=False, config={"displaylogo": False})])], className="col-lg-9 col-sm-12 col-xs-12" if(g.Labels != None) else "col-lg-12 col-sm-12 col-xs-12"), html.Div([dcc.Graph(id='general-graph', animate=False, config={"displaylogo": False})])], className="col-lg-9 col-sm-12 col-xs-12" if(g.Labels != None) else "col-lg-12 col-sm-12 col-xs-12"),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment