display the current losses on visdom display: dictionary of error labels and values Parameters: epoch (int) -- current epoch counter_ratio (float) -- progress (percentage) in the current epoch, between 0 to 1 losses (OrderedDict) -- training lo
(self, epoch, counter_ratio, losses)
| 47 | self.print_url(self.vis) |
| 48 | |
| 49 | def plot_current_losses(self, epoch, counter_ratio, losses): |
| 50 | """display the current losses on visdom display: dictionary of error labels and values |
| 51 | |
| 52 | Parameters: |
| 53 | epoch (int) -- current epoch |
| 54 | counter_ratio (float) -- progress (percentage) in the current epoch, between 0 to 1 |
| 55 | losses (OrderedDict) -- training losses stored in the format of (name, float) pairs |
| 56 | """ |
| 57 | if not hasattr(self, 'plot_data'): |
| 58 | self.plot_data = {'X': [], 'Y': [], 'legend': list(losses.keys())} |
| 59 | self.plot_data['X'].append(epoch + counter_ratio) |
| 60 | self.plot_data['Y'].append([losses[k] for k in self.plot_data['legend']]) |
| 61 | try: |
| 62 | self.vis.line( |
| 63 | X=np.stack([np.array(self.plot_data['X'])] * len(self.plot_data['legend']), 1), |
| 64 | Y=np.array(self.plot_data['Y']), |
| 65 | opts={ |
| 66 | 'title': self.name + ' loss over time', |
| 67 | 'legend': self.plot_data['legend'], |
| 68 | 'xlabel': 'epoch', |
| 69 | 'ylabel': 'loss'}, |
| 70 | win=self.display_id) |
| 71 | except VisdomExceptionBase: |
| 72 | self.create_visdom_connections() |
| 73 | |
| 74 | # losses: same format as |losses| of plot_current_losses |
| 75 | def print_current_losses(self, epoch, iters, losses, t_comp, t_data): |
nothing calls this directly
no test coverage detected