def setUp(self): self.parser = train.create_parser()
init_channels: int, classes: int, layers: int, auxiliary: bool) -> int: model = Network(init_channels, classes, layers, auxiliary, genotype) model_size_mb = utils.count_parameters_in_MB(model) batch_size = 0 consumption = 0 while consumption < (memory - 500): batch_size += 1 consumption = batch_model.predict([[model_size_mb, batch_size]]) log.info("Predicted consumption is %d MB", consumption) return batch_size if __name__ == '__main__': log = logging.getLogger("batch_train") parser = create_parser() parser.add_argument('--archs', type=str, required=False, nargs='+', help='list of architectures to use', default=[ arch for arch, gen in genotypes.__dict__.items() if isinstance(gen, Genotype) ]) parser.add_argument('--batch_model', type=str, default="batch_predict.pkl", help='list of architectures to use') args = parser.parse_args()
def test_lc(self): parser = train.create_parser() namespace = parser.parse_args(("--lc", )) self.assertIsNotNone(namespace.lc)
import argparse import train train_commands = [ # anoCAE "-d LEGO_light/SV -a anoCAE -b 8 -l mssim -c rgb -e 60 -r custom --inspect", # baselineCAE "-d LEGO_light/SV -a baselineCAE -b 8 -l mssim -c rgb -e 60 -r custom --inspect", # inceptionCAE "-d LEGO_light/SV -a inceptionCAE -b 8 -l mssim -c rgb -e 60 -r custom --inspect", # mvtecCAE "-d LEGO_light/SV -a mvtecCAE -b 8 -l mssim -c rgb -e 60 -r custom --inspect", # resnetCAE "-d LEGO_light/SV -a resnetCAE -b 8 -l mssim -c rgb -e 60 -r custom --inspect", # skipCAE "-d LEGO_light/SV -a skipCAE -b 8 -l mssim -c rgb -e 60 -r custom --inspect", ] parser = train.create_parser() for command in train_commands: args_list = command.split(" ") args = parser.parse_args(args_list) try: train.main(args) except Exception: pass
def test_no_lc(self): commands = train.create_parser().parse_args(("--model", "model.txt")) words = train.prepare_line('I hate unittests.,,apple;', commands) for word in words: self.assertTrue(word.isalpha())
def test_lc(self): commands = train.create_parser().parse_args(("--lc", )) words = train.prepare_line("I don't like unittest__oh-oh", commands) for word in words: self.assertTrue(word.islower()) self.assertTrue(word.isalpha())
def test_model(self): parser = train.create_parser() namespace = parser.parse_args(("--mode", "model.txt")) self.assertEqual(namespace.model, "model.txt")
def test_input_dir(self): parser = train.create_parser() namespace = parser.parse_args(("--input-dir", "input/")) self.assertEqual("input/", namespace.input_dir)
def run_experiments(experiments_filepath): parser = create_parser() args = parser.parse_args(args=[]) args.config_file = experiments_filepath run(args, parser)