def on_epoch_end(self, epoch, logs={}): self.loss.append(logs["val_loss"]) if len(self.loss) == 1 or min(self.loss[:-1]) > self.loss[-1]: ev = Evaluator(self.model, SIGMA_REL_TH) ev.process_NED2012(self.NED2012_path) ev.print_res() sd_SD, sd_SI = ev.get_res() logs["NED2012 SD component error"] = np.array(sd_SD, dtype="float64") logs["NED2012 SI component error"] = np.array(sd_SI, dtype="float64")
verbose=2, callbacks=callbacks, ) print("NoiseNet training completed. Path to model: %s" % model_path) elif args.mode == 'eval': print("NoiseNet evaluation mode.") print("Evaluating model %s" % model_path) try: netBNPE = load_model( model_path, compile=False, custom_objects={"SIGMA_EPSILON": SIGMA_EPSILON}) print("Model %s successfully loaded" % model_path) except: print("Failed to load model %s" % model_path) sys.exit(0) our_dir = os.path.dirname(model_path) ev = Evaluator(netBNPE, SIGMA_REL_TH, 1, our_dir) # perform test on pure gaussian noise ev.pure_noise_test() if args.NED2012_path is None: print( "NED2012_path not specified. Skipping NED2012 evaluation stage" ) else: # perform test on NED2012 database ev.process_NED2012(args.NED2012_path) else: Warning("Unsupported mode")