fastai / fastai_dev

fast.ai early development experiments
Apache License 2.0
638 stars 350 forks source link

skip_start argument of the plot_loss Recorder method only affects train loss #298

Closed mikonapoli closed 4 years ago

mikonapoli commented 4 years ago

It is a very simple change in notebook n. 13 (learner): the plot_loss method of the Recorder class should be

def plot_loss(self, skip_start=5, with_valid=True):
        plt.plot(self.losses[skip_start:], label='train')
        if with_valid:
            plt.plot(self.iters, L(self.values[skip_start:]).itemgot(1), label='valid')
            plt.legend()

Instead of the current

def plot_loss(self, skip_start=5, with_valid=True):
        plt.plot(self.losses[skip_start:], label='train')
        if with_valid:
            plt.plot(self.iters, L(self.values).itemgot(1), label='valid')
            plt.legend()
sgugger commented 4 years ago

Good catch, will fix tomorrow. In general, you can directly open a PR for a change like this, instead of filing an issue.

sgugger commented 4 years ago

Oh looking more into it, it's not self.skip_start that should be used since the validation losses are fewer than the training losses. The right index has to be computed.