'i want to change something in the learner.recorder.plot_losses function in fastai
I have a task where i need to only plot the training loss not the validation loss of the plot_losses function in the fastai library with learner object having recorder class, but I'm not able to properly implement the same. I'm using the fastai v1 for this purpose due to project restrictions Here is the github code for the same.
class Recorder(LearnerCallback):
"A `LearnerCallback` that records epoch, loss, opt and metric data during training."
def plot_losses(self, skip_start:int=0, skip_end:int=0, return_fig:bool=None, show_grid:bool=False)->Optional[plt.Figure]:
"Plot training and validation losses."
fig, ax = plt.subplots(1,1)
losses = self._split_list(self.losses, skip_start, skip_end)
iterations = self._split_list(range_of(self.losses), skip_start, skip_end)
ax.plot(iterations, losses, label='Train')
val_iter = self._split_list_val(np.cumsum(self.nb_batches), skip_start, skip_end)
val_losses = self._split_list_val(self.val_losses, skip_start, skip_end)
ax.plot(val_iter, val_losses, label='Validation')
plt.grid(show_grid)
ax.set_ylabel('Loss')
ax.set_xlabel('Batches processed')
ax.legend()
if ifnone(return_fig, defaults.return_fig): return fig
if not IN_NOTEBOOK: plot_sixel(fig)
I tried commenting out the " ax.plot(val_iter, val_losses, label='Validation')" line in the above function and wrote it before using the function , but when I try to use the function as: """ learn.recorder.plot_losses() """ it still shows the validation curve in the plot.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
