-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplot_both.py
More file actions
52 lines (37 loc) · 1.21 KB
/
plot_both.py
File metadata and controls
52 lines (37 loc) · 1.21 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
41
42
43
44
45
46
47
48
49
50
51
52
import numpy as np
import matplotlib.pyplot as plt
"""
1. Test에 해당하는 부분만 추출한다.
"""
tgt_lines_AB = []
tgt_lines_BA = []
max_len = 100
with open("DCP_origin.csv", "r") as f:
lines = f.readlines() # 8 -> 23 -> 39 (16)
for i in range(7, len(lines), 15):
A2B = lines[i].strip("\n")
B2A = lines[i+2].strip("\n")
# print(A2B.split(", "))
A2B_list = [j.split(": ")[1] for j in A2B.split(", ") if j[0] != "C"]
B2A_list = [j.split(": ")[1] for j in B2A.split(", ")]
if A2B_list[0] == f"{max_len}":
break
tgt_lines_AB.append(A2B_list[1:])
tgt_lines_BA.append(B2A_list[1:])
tgt_lines_AB = np.array(tgt_lines_AB, np.float32)
tgt_lines_BA = np.array(tgt_lines_BA, np.float32)
t1 = np.array(range(len(tgt_lines_AB)))
with open("DCP_normal.csv", "r") as f:
lines = [list(eval(i.strip("\n"))) for i in f.readlines()]
arr1 = np.array(lines, np.float32)
t2 = np.array(range(len(arr1)))
t = t1 if len(t1) < len(t2) else t2
target = "mse_ab"
plt.title(f"{target}")
plt.grid(True)
plt.plot(t, arr1[:, 10])
plt.plot(t, tgt_lines_AB[:, 7])
plt.legend(["my code", "origin"])
plt.xlabel("epochs")
plt.ylabel(f"{target}")
plt.show()