4cec9b076727d32c4f31f838c32567fc51fa1e9d,precise/scripts/train.py,Trainer,__init__,#Trainer#Any#,71

Before Change


    def __init__(self, parser=None):
        parser = parser or ArgumentParser()
        add_to_parser(parser, self.usage, True)
        args = TrainData.parse_args(parser)
        self.args = args = self.process_args(args) or args

        if args.invert_samples and not args.samples_file:
            parser.error("You must specify --samples-file when using --invert-samples")
        if args.samples_file and not isfile(args.samples_file):
            parser.error("No such file: " + (args.invert_samples or args.samples_file))
        if not 0.0 <= args.sensitivity <= 1.0:
            parser.error("sensitivity must be between 0.0 and 1.0")

        inject_params(args.model)
        save_params(args.model)
        params = ModelParams(skip_acc=args.no_validation, extra_metrics=args.extra_metrics,
                             loss_bias=1.0 - args.sensitivity, freeze_till=args.freeze_till)
        self.model = create_model(args.model, params)
        self.train, self.test = self.load_data(self.args)

        from keras.callbacks import ModelCheckpoint, TensorBoard
        checkpoint = ModelCheckpoint(args.model, monitor=args.metric_monitor,
                                     save_best_only=args.save_best)
        epoch_fiti = Fitipy(splitext(args.model)[0] + ".epoch")
        self.epoch = epoch_fiti.read().read(0, int)

        def on_epoch_end(a, b):
            self.epoch += 1
            epoch_fiti.write().write(self.epoch, str)

        self.model_base = splitext(self.args.model)[0]

        if args.samples_file:
            self.samples, self.hash_to_ind = self.load_sample_data(args.samples_file, self.train)
        else:
            self.samples = set()
            self.hash_to_ind = {}

        self.callbacks = [
            checkpoint, TensorBoard(
                log_dir=self.model_base + ".logs",
            ), LambdaCallback(on_epoch_end=on_epoch_end)

After Change


        super().__init__(args)

        if args.invert_samples and not args.samples_file:
            raise ValueError("You must specify --samples-file when using --invert-samples")
        if args.samples_file and not isfile(args.samples_file):
            raise ValueError("No such file: " + (args.invert_samples or args.samples_file))
        if not 0.0 <= args.sensitivity <= 1.0:
            raise ValueError("sensitivity must be between 0.0 and 1.0")
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 4

Instances


Project Name: MycroftAI/mycroft-precise
Commit Name: 4cec9b076727d32c4f31f838c32567fc51fa1e9d
Time: 2019-10-31
Author: matthew331199@gmail.com
File Name: precise/scripts/train.py
Class Name: Trainer
Method Name: __init__


Project Name: deepfakes/faceswap
Commit Name: f16ea566f0565e7fb1eee3477e66e51c3ba87b1c
Time: 2018-04-04
Author: 36920800+torzdf@users.noreply.github.com
File Name: tools/sort.py
Class Name:
Method Name:


Project Name: moskomule/senet.pytorch
Commit Name: ac695a5b4bf38853367f2c37ce104caba111576f
Time: 2018-12-29
Author: hataya@keio.jp
File Name: imagenet.py
Class Name:
Method Name: