This repository has been archived by the owner on Sep 19, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
graph.py
56 lines (47 loc) · 1.63 KB
/
graph.py
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
53
54
55
56
# Code to upload graphs to plotly
import plotly
import datetime
# Don't steal my account.
plotly.tools.set_credentials_file(username='srush', api_key='UQ8nYG8eVknB63NjMq9k')
import re
import plotly.plotly as py
from plotly.graph_objs import *
import sys
def escape_ansi(line):
ansi_escape = re.compile(r'(\x9B|\x1B\[)[0-?]*[ -\/]*[@-~]')
return ansi_escape.sub('', line).strip()
def get_lines():
while True:
input = ""
c = sys.stdin.readline()
if c == "": break
yield c
ppls = []
xs = []
old = py.get_figure("srush", 1)["data"][-7:]
for l in get_lines():
q = escape_ansi(l.strip())
print(q)
if q.startswith("Epoch"):
print("Epoch")
# Epoch 1 ; Batch 50/183 ; LR 1.0000 ; Throughput 1410/518/892 total/src/targ tokens/sec ; PPL 110737.21 ; Free mem 2447245312
epoch, batch, lr, speed, ppl, mem = q.split(";")
ppl = float(ppl.split()[1])
epoch = float(epoch.split()[1])
# Ignore first two epochs (too noisy)
#if epoch <= 2.0: continue
batch_term = batch.split()[1].split("/")
batch = float(batch_term[0]) / float(batch_term[1])
ppls.append(ppl)
xs.append(epoch + batch)
trace0 = Scatter(
x=xs,
y=ppls,
name ="Test Run" + str(datetime.date.today()))
data = Data(old + [trace0])
print("Sending Graph Data")
py.plot({"data":data, "layout": {"title":"Performance",
"xaxis" : {"title": "Epoch"},
"yaxis" : {"title": "ppl"},
}},
auto_open = False, filename = 'my plot')