code/water/train_network_real_large.py
def on_epoch_end(self, trainer: pl.Trainer, pl_module: ParticleNetLightning):
        """ Check if we should save a checkpoint after every train batch """
        epoch = trainer.current_epoch
        if epoch % self.save_step_frequency == 0 or epoch == pl_module.epoch_num -1:
            filename = os.path.join(self.filepath, f"{self.prefix}_{epoch}.ckpt")
            scaler_filename = os.path.join(self.filepath, f"scaler_{epoch}.npz")

            ckpt_path = os.path.join(trainer.checkpoint_callback.dirpath, filename)
            trainer.save_checkpoint(ckpt_path)
            np.savez(scaler_filename,
                     mean=pl_module.training_mean,
                     var=pl_module.training_var,
                     )
            # joblib.dump(pl_module.train_data_scaler, scaler_filename)
 Check if we should save a checkpoint after every train batch 
Check if we should save a checkpoint after every train batch
Check if we should save a checkpoint after every train batch
def on_epoch_end(self, trainer: pl.Trainer, pl_module: ParticleNetLightning):
        epoch = trainer.current_epoch
        if epoch % self.save_step_frequency == 0 or epoch == pl_module.epoch_num -1:
            filename = os.path.join(self.filepath, f"{self.prefix}_{epoch}.ckpt")
            scaler_filename = os.path.join(self.filepath, f"scaler_{epoch}.npz")
            ckpt_path = os.path.join(trainer.checkpoint_callback.dirpath, filename)
            trainer.save_checkpoint(ckpt_path)
            np.savez(scaler_filename,
                     mean=pl_module.training_mean,
                     var=pl_module.training_var,
                     )
def on_epoch_end ( self , trainer : pl . Trainer , pl_module : ParticleNetLightning ) : epoch = trainer . current_epoch if epoch % self . save_step_frequency == 0 or epoch == pl_module . epoch_num - 1 : filename = os . path . join ( self . filepath , f"{self.prefix}_{epoch}.ckpt" ) scaler_filename = os . path . join ( self . filepath , f"scaler_{epoch}.npz" ) ckpt_path = os . path . join ( trainer . checkpoint_callback . dirpath , filename ) trainer . save_checkpoint ( ckpt_path ) np . savez ( scaler_filename , mean = pl_module . training_mean , var = pl_module . training_var , )
Check if we should save a checkpoint after every train batch
Check if we should save a checkpoint after every train batch
""" Check if we should save a checkpoint after every train batch """ # joblib.dump(pl_module.train_data_scaler, scaler_filename)
self
trainer
pl.Trainer
pl_module
ParticleNetLightning