I need to plot only training curve in the fastai library using the learner.recorder.plot_losses() function . FASTAI devs pls help

I have a task where I need to only plot the training loss and not the validation loss of the plot_losses function in the fastai library with learner object having recorder class, but I am not able to properly implement the same.

I am 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.

Topic fastai python-3.x computer-vision deep-learning machine-learning

Category Data Science

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.