Plot graph. Data is a 1D tensor. args: fig_num: Figure number. title: Title of figure.
(a: torch.Tensor, fig_num = None, title = None)
| 30 | |
| 31 | |
| 32 | def plot_graph(a: torch.Tensor, fig_num = None, title = None): |
| 33 | """Plot graph. Data is a 1D tensor. |
| 34 | args: |
| 35 | fig_num: Figure number. |
| 36 | title: Title of figure. |
| 37 | """ |
| 38 | a_np = a.squeeze().cpu().clone().detach().numpy() |
| 39 | if a_np.ndim > 1: |
| 40 | raise ValueError |
| 41 | fig = plt.figure(fig_num) |
| 42 | # plt.tight_layout() |
| 43 | plt.cla() |
| 44 | plt.plot(a_np) |
| 45 | if title is not None: |
| 46 | plt.title(title) |
| 47 | draw_figure(fig) |
no test coverage detected