11[ ![ Binder] ( https://mybinder.org/badge.svg )] ( https://mybinder.org/v2/gh/rsokl/liveplot/master?filepath=LivePlot_Demo.ipynb )
22
3- # liveplot
4- Log and plot metrics during train/test time for a neural network (or whatever, really). ` liveplot `
5- provides convenient i/o functions for saving, loading, and recreating liveplot sessions. It also provides
3+ # nogging
4+ Log and plot metrics during train/test time for a neural network (or whatever, really). ` nogging `
5+ provides convenient i/o functions for saving, loading, and recreating nogging sessions. It also provides
66an interface for accessing logged metrics as [ xarray data sets] ( http://xarray.pydata.org/en/stable/index.html ) . This
7- functionality, availabile via ` liveplot .xarray` , permits users to seamlessly access their logged metrics as N-dimensional arrays with named axes.
7+ functionality, availabile via ` nogging .xarray` , permits users to seamlessly access their logged metrics as N-dimensional arrays with named axes.
88
9- Please consult the [ demo notebook] ( https://github.com/rsokl/LivePlot/blob/master/LivePlot_Demo.ipynb ) for a summary of ` liveplot ` 's functionality.
9+ Please consult the [ demo notebook] ( https://github.com/rsokl/LivePlot/blob/master/LivePlot_Demo.ipynb ) for a summary of ` nogging ` 's functionality.
1010
11- ![ liveplot ] ( https://user-images.githubusercontent.com/29104956/52166468-bf425700-26db-11e9-9324-1fc83d4bc71d.gif )
11+ ![ nogging ] ( https://user-images.githubusercontent.com/29104956/52166468-bf425700-26db-11e9-9324-1fc83d4bc71d.gif )
1212
1313
14- ## Installing liveplot
15- Clone/download this repository, navigate to the ` liveplot ` directory, and run:
14+ ## Installing nogging
15+ Clone/download this repository, navigate to the ` nogging ` directory, and run:
1616``` shell
1717python setup.py install
1818```
@@ -21,7 +21,7 @@ python setup.py install
2121### Creating a live plot
2222``` python
2323import numpy as np
24- from liveplot import create_plot
24+ from nogging import create_plot
2525
2626% matplotlib notebook
2727
@@ -50,191 +50,9 @@ for i, x in enumerate(np.linspace(0, 10, 100)):
5050plotter.plot() # ensures final data gets plotted
5151
5252
53- from liveplot import save_metrics
53+ from nogging import save_metrics
5454
55- # save metrics from liveplot instance
55+ # save metrics from nogging instance
5656save_metrics(" tmp.npz" , plotter)
5757```
5858
59- ### Recreating plot from saved metrics
60- ``` python
61- from liveplot import load_metrics, recreate_plot
62-
63- train, test = load_metrics(" tmp.npz" )
64-
65- colors = {" accuracy" :dict (train = " C4" , test = " C6" ),
66- " loss" :" red" }
67-
68- new_plotter, fig, ax = recreate_plot(train_metrics = train,
69- test_metrics = test,
70- colors = colors)
71- ```
72-
73- ## Documentation
74-
75- ```
76- def create_plot(metrics, refresh=0., plot_title=None, figsize=None, track_time=True):
77- """ Create matplotlib figure/axes, and a live-plotter, which publishes
78- "live" training/testing metric data, at a batch and epoch level, to
79- the figure.
80-
81- Parameters
82- ----------
83- metrics : Union[str, Sequence[str], Dict[str, valid-color]
84- The name, or sequence of names, of the metric(s) that will be plotted.
85-
86- `metrics` can also be a dictionary, specifying the colors used to plot
87- the metrics. Two mappings are valid:
88- - metric-name -> color-value (specifies train-metric color only)
89- - metric-name -> {train/test : color-value}
90-
91- refresh : float, optional (default=0.)
92- Sets the plot refresh rate in seconds.
93-
94- A refresh rate of 0. updates the once every 1/1000 seconds. A
95- negative refresh rate will draw the plot only at the end of the session.
96-
97- plot_title : Optional[str]
98- Specifies the title used on the plot.
99-
100- figsize : Optional[Sequence[int, int]]
101- Specifies the width and height, respectively, of the figure.
102-
103- track_time : bool, default=True
104- If `True`, the total time of plotting is annotated in within the first axes
105-
106- Returns
107- -------
108- Tuple[liveplot.LivePlot, matplotlib.figure.Figure, numpy.ndarray(matplotlib.axes.Axes)]
109- (LivePlot-instance, figure, array-of-axes)
110-
111-
112- def recreate_plot(liveplot=None, *, train_metrics=None, test_metrics=None, colors=None):
113- """ Recreate a plot from a LivePlot instance or from train/test metric dictionaries.
114-
115- Parameters
116- ----------
117- liveplot : Optional[liveplot.LivePlot]
118- An existing liveplot object.
119-
120- Keyword-Only Arguments
121- ----------------------
122- train_metrics : Optional[OrderedDict[str, Dict[str, numpy.ndarray]]]
123- metric_name -> {"batch_data": array,
124- "epoch_data": array,
125- "epoch_domain": array}
126-
127- test_metrics : Optional[OrderedDict[str, Dict[str, numpy.ndarray]]]
128- metric_name -> {"batch_data": array,
129- "epoch_data": array,
130- "epoch_domain": array}
131-
132- colors : Optional[Dict[str, color-value], Dict[str, Dict[str, color-value]]
133- Specifying train-time metric colors only:
134- metric-name -> color-value
135-
136- Specifying train or test-time metric colors:
137- metric-name -> {train/test -> color-value}
138-
139- Returns
140- -------
141- Tuple[liveplot.LivePlot, matplotlib.figure.Figure, numpy.ndarray(matplotlib.axes.Axes)]
142- (LivePlot-instance, figure, array-of-axes)"""
143-
144-
145-
146- def save_metrics(path, liveplot=None, *, train_metrics=None, test_metrics=None):
147- """ Save live-plot metrics to a numpy zipped-archive (.npz). A LivePlot-instance
148- can be supplied, or train/test metrics can be passed explicitly to the function.
149-
150- Parameters
151- ----------
152- path: PathLike
153- The file-path used to save the archive. E.g. 'path/to/saved_metrics.npz'
154-
155- liveplot : Optional[liveplot.LivePlot]
156- The LivePlot instance whose metrics will be saves.
157-
158- train_metrics : Optional[OrderedDict[str, Dict[str, numpy.ndarray]]]]
159-
160- metric-name -> {batch_data -> array, epoch_domain -> array, epoch_data -> array}
161-
162- test_metrics : Optional[OrderedDict[str, Dict[str, numpy.ndarray]]]]
163- metric-name -> {batch_data -> array, epoch_domain -> array, epoch_data -> array}"""
164-
165-
166- def load_metrics(path):
167- """ Load liveplot metrics from a numpy archive.
168-
169- Parameters
170- ----------
171- path : PathLike
172- Path to numpy archive.
173-
174- Returns
175- -------
176- Tuple[OrderedDict[str, Dict[str, numpy.ndarray]], OrderedDict[str, Dict[str, numpy.ndarray]]]]
177- (train-metrics, test-metrics)"""
178-
179- class LivePlot:
180- """ Plots batch-level and epoch-level summary statistics of the training and
181- testing metrics of a model during a session.
182-
183-
184- Attributes
185- ----------
186- train_metrics : OrderedDict[str, Dict[str, numpy.ndarray]]
187- Stores training metric results data and plot-objects.
188-
189- test_metrics : OrderedDict[str, Dict[str, numpy.ndarray]]
190- Stores testing metric results data and plot-objects.
191-
192- metric_colors : Dict[str, Dict[str, color-value]]
193- {metric-name -> {'train'/'test' -> color-value}}
194-
195- Methods
196- -------
197- plot(self)
198- Plot data, irrespective of the refresh rate. This should only
199- be called if you are generating a static plot.
200-
201- plot_objects(self)
202- The figure-instance of the plot, and the axis-instance for each metric.
203-
204- Returns
205- -------
206- Tuple[matplotlib.figure.Figure, numpy.ndarray(matplotlib.axes.Axes)]
207-
208- plot_test_epoch(self)
209-
210- plot_train_epoch(self)
211-
212- set_test_batch(self, metrics, batch_size)
213-
214- Parameters
215- ----------
216- metrics : Dict[str, Real]
217- Mapping of metric-name to value. Only those metrics that were
218- registered when initializing LivePlot will be recorded.
219-
220- batch_size : Integral
221- The number of samples in the batch used to produce the metrics.
222- Used to weight the metrics to produce epoch-level statistics.
223-
224- set_train_batch(self, metrics, batch_size, plot=True)
225-
226- Parameters
227- ----------
228- metrics : Dict[str, Real]
229- Mapping of metric-name to value. Only those metrics that were
230- registered when initializing LivePlot will be recorded.
231-
232- batch_size : Integral
233- The number of samples in the batch used to produce the metrics.
234- Used to weight the metrics to produce epoch-level statistics.
235-
236- plot : bool
237- If True, plot the batch-metrics (adhering to the refresh rate)
238-
239- show(self)
240- Calls `matplotlib.pyplot.show()`. For visualizing a static-plot. """```
0 commit comments