MCPcopy Create free account
hub / github.com/JunlinHan/DCLGAN / plot_current_losses

Method plot_current_losses

util/visualizer.py:191–223  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

189 webpage.save()
190
191 def plot_current_losses(self, epoch, counter_ratio, losses):
192 """display the current losses on visdom display: dictionary of error labels and values
193
194 Parameters:
195 epoch (int) -- current epoch
196 counter_ratio (float) -- progress (percentage) in the current epoch, between 0 to 1
197 losses (OrderedDict) -- training losses stored in the format of (name, float) pairs
198 """
199 if len(losses) == 0:
200 return
201
202 plot_name = '_'.join(list(losses.keys()))
203
204 if plot_name not in self.plot_data:
205 self.plot_data[plot_name] = {'X': [], 'Y': [], 'legend': list(losses.keys())}
206
207 plot_data = self.plot_data[plot_name]
208 plot_id = list(self.plot_data.keys()).index(plot_name)
209
210 plot_data['X'].append(epoch + counter_ratio)
211 plot_data['Y'].append([losses[k] for k in plot_data['legend']])
212 try:
213 self.vis.line(
214 X=np.stack([np.array(plot_data['X'])] * len(plot_data['legend']), 1),
215 Y=np.array(plot_data['Y']),
216 opts={
217 'title': self.name,
218 'legend': plot_data['legend'],
219 'xlabel': 'epoch',
220 'ylabel': 'loss'},
221 win=self.display_id - plot_id)
222 except VisdomExceptionBase:
223 self.create_visdom_connections()
224
225 # losses: same format as |losses| of plot_current_losses
226 def print_current_losses(self, epoch, iters, losses, t_comp, t_data):

Callers 1

train.pyFile · 0.80

Calls 1

Tested by

no test coverage detected