Ejemplo n.º 1
0
            train_loss = framework.train(network,
                                         train_loader,
                                         loss_fn,
                                         optim,
                                         epoch,
                                         writer=writer,
                                         early_stop=args.early_stop)

            prec_rec = PrecRec(n_thresholds=100)
            framework.test(
                network,
                val_loader,
                loss_fn,
                [prec_rec],
                epoch,
                writer=writer,
                early_stop=args.early_stop,
            )

            results = prec_rec.get_dict()
            for key in results:
                writer.add_scalar(f'Test/{key}', results[key], epoch)

            scheduler.step(train_loss)

            framework.save_checkpoint(epoch,
                                      0.,
                                      network,
                                      optim,
                                      path=args.artifacts)
Ejemplo n.º 2
0
            for epoch in range(start_epoch, args.epochs):
                train_loss = framework.train(network,
                                             train_loader,
                                             loss_fn,
                                             optim,
                                             epoch,
                                             early_stop=args.early_stop,
                                             logger=logger)

                score = framework.test(network,
                                       val_loader,
                                       criteria,
                                       early_stop=args.early_stop,
                                       logger=logger)
                scheduler.step(train_loss)
                framework.save_checkpoint(epoch,
                                          score,
                                          network,
                                          optim,
                                          path=args.artifacts)

                if score > best_score:
                    best_score = score
                    fname = 'model_best_{:.2f}.pth.tar'.format(best_score)
                    framework.save_checkpoint(epoch,
                                              best_score,
                                              network,
                                              optim,
                                              path=args.artifacts,
                                              fname=fname)