def before_fit(self):
    try:
        self.experiment = neptune.get_experiment()
    except ValueError:
        print('No active experiment. Please invoke `neptune.create_experiment()` before this callback.')
    try:
        self.experiment.set_property('n_epoch', str(self.learn.n_epoch))
        self.experiment.set_property('model_class', str(type(self.learn.model)))
    except:
        print(f'Did not log all properties. Check properties in the {neptune.get_experiment()}.')
    try:
        with tempfile.NamedTemporaryFile(mode='w') as f:
            with open(f.name, 'w') as g:
                g.write(repr(self.learn.model))
            self.experiment.log_artifact(f.name, 'model_summary.txt')
    except:
        print('Did not log model summary. Check if your model is PyTorch model.')
    if (self.log_model_weights and (not hasattr(self.learn, 'save_model'))):
        print('Unable to log model to Neptune.\n', 'Use "SaveModelCallback" to save model checkpoints that will be logged to Neptune.')
def before_fit(self):
    try:
        self.experiment = neptune.get_experiment()
    except ValueError:
        print('No active experiment. Please invoke `neptune.create_experiment()` before this callback.')
    try:
        self.experiment.set_property('n_epoch', str(self.learn.n_epoch))
        self.experiment.set_property('model_class', str(type(self.learn.model)))
    except:
        print(f'Did not log all properties. Check properties in the {neptune.get_experiment()}.')
    try:
        with tempfile.NamedTemporaryFile(mode='w') as f:
            with open(f.name, 'w') as g:
                g.write(repr(self.learn.model))
            self.experiment.log_artifact(f.name, 'model_summary.txt')
    except:
        print('Did not log model summary. Check if your model is PyTorch model.')
    if (self.log_model_weights and (not hasattr(self.learn, 'save_model'))):
        print('Unable to log model to Neptune.\n', 'Use "SaveModelCallback" to save model checkpoints that will be logged to Neptune.')