wangwei created SINGA-412:
-----------------------------
Summary: Log visualization API
Key: SINGA-412
URL: https://issues.apache.org/jira/browse/SINGA-412
Project: Singa
Issue Type: Improvement
Reporter: wangwei
The current visualization API in the Rafiki model.py can be simplified.
{code:java}
class Logger:
''' For logging data to web front-end.
It supports logging text messages via log(prefix), and logging key-value
pairs log(**kwargs), e.g., log(loss=0.1, accuracy=0.4, epoch=1, step=34); To
visualize the data on the web page, the plot has to be defined before logging
the data via define_plot().
TODO log (numpy) array.
Example:
log = Logger()
log.log('start training')
log.define_plot('train loss and accuracy', yaxes=['loss', 'acc'],
xaxis='epoch')
for epoch in range(10):
log.log(loss=0.1, acc=0.4, epoch=epoch)
# or
# log.log(loss=0.1, epoch=epoch)
# log.log(acc=0.4, epoch=epoch)
'''
def define_plot(name, yaxes = ['loss'], xaxis='epoch')
''' define the plot to be visualized in the web page.
Args:
name: string for plot name.
yaxes: a list of string for the names of the items/metrics, e.g., loss,
accuracy, learning rate, etc. One name corresponds to one key in log().
xaxis: string for the xaxis, e.g., epoch or step to indicate the
progress. It also corresponds to on key in log().
'''
def log(prefix='', **kwargs)
''' log one piece of msg and key-val pairs.
Args:
prefix: text string.
kwargs: key-value pairs. key is a string and value is a number. To
visualize one key-value, the plot must be defined via define_plot, and the key
must be included in the yaxes, and another key must be the xaxis. For example,
the loss and acc in log(loss=0.1, acc=0.4, epoch=1, step=34) can be visualized
in the plot generated by define_plot('loss and acc', yaxes=['loss', 'acc'],
xaxis='epoch')
'''
{code}
For each log entry, we must also keep the time. In the front end, we can plot
either the yaxes-xaxis or yaxes-time.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)