-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.py
More file actions
41 lines (31 loc) · 1.01 KB
/
utils.py
File metadata and controls
41 lines (31 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import numpy as np
import matplotlib.pyplot as plt
def index_sequence_to_string(index_sequence):
return ", ".join([str(x) for x in index_sequence])
def multi_hot_to_text(multi_hot):
return " ".join(
[str(int(x)) for x in multi_hot]
)
def decode(encoder, indices):
vocabulary = encoder.get_vocabulary()
strings = [vocabulary[index] for index in indices]
return " ".join(strings)
def render_history(history):
plt.title("losses")
plt.plot(history.history["loss"], label="loss")
plt.plot(history.history["val_loss"], label="val_loss")
plt.legend()
plt.show()
plt.close()
plt.title("Accuracies")
plt.plot(history.history["accuracy"], label="accuracy")
plt.plot(history.history["val_accuracy"], label="val_accuracy")
plt.legend()
plt.show()
plt.close()
def compare_histories(history_list):
for training_name, history in history_list.items():
plt.plot(history["val_accuracy"], label=training_name)
plt.legend()
plt.title("Comparision of val_accuracy")
plt.show()