dar-tau commited on
Commit
5e8795d
·
verified ·
1 Parent(s): e991bcb

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -2
app.py CHANGED
@@ -14,7 +14,7 @@ def analyze_sentence(index):
14
  attn_map_shape = row['attention_maps_shape'][1:]
15
  seq_len = attn_map_shape[1]
16
  attn_maps = np.array(row['attention_maps']).reshape(*attn_map_shape)
17
- plot = sns.heatmap(attn_maps.sum(0))
18
  plt.xticks(np.arange(seq_len - 1) + 0.5,
19
  tokenizer.tokenize(text, add_special_tokens=False), rotation=90);
20
  plt.yticks(np.arange(seq_len - 1) + 0.5,
@@ -25,6 +25,6 @@ def analyze_sentence(index):
25
  return text, plot
26
 
27
 
28
- iface = gr.Interface(fn=analyze_sentence, inputs=[gr.Dropdown(choices=dataset['text'], type='index')],
29
  outputs=[gr.Label(), gr.Plot(label="Plot")])
30
  iface.launch()
 
14
  attn_map_shape = row['attention_maps_shape'][1:]
15
  seq_len = attn_map_shape[1]
16
  attn_maps = np.array(row['attention_maps']).reshape(*attn_map_shape)
17
+ plot = sns.heatmap(attn_maps.sum(0)[1:, 1:])
18
  plt.xticks(np.arange(seq_len - 1) + 0.5,
19
  tokenizer.tokenize(text, add_special_tokens=False), rotation=90);
20
  plt.yticks(np.arange(seq_len - 1) + 0.5,
 
25
  return text, plot
26
 
27
 
28
+ iface = gr.Interface(fn=analyze_sentence, inputs=[gr.Dropdown(choices=dataset['text'], index=0, type='index')],
29
  outputs=[gr.Label(), gr.Plot(label="Plot")])
30
  iface.launch()