def train_and_test(network, trainer, train_source, test_source, minibatch_size, epoch_size, restore, profiling=False): # define mapping from intput streams to network inputs input_map = { network['feature']: train_source.streams.features, network['label']: train_source.streams.labels } # Train all minibatches if profiling: cntk.start_profiler(sync_gpu=True) training_session( trainer=trainer, mb_source=train_source, var_to_stream=input_map, mb_size=minibatch_size, progress_frequency=epoch_size, checkpoint_config=CheckpointConfig(frequency=epoch_size, filename=os.path.join( model_path, "ConvNet_CIFAR10_DataAug"), restore=restore), cv_config=CrossValidationConfig(source=test_source, mb_size=minibatch_size)).train() if profiling: cntk.stop_profiler()
def train_and_test(network, trainer, train_source, test_source, progress_writers, minibatch_size, epoch_size, restore, profiling=False): # define mapping from intput streams to network inputs input_map = { network['feature']: train_source.streams.features, network['label']: train_source.streams.labels } training_session = cntk.training_session( training_minibatch_source = train_source, trainer = trainer, model_inputs_to_mb_source_mapping = input_map, mb_size_schedule = cntk.minibatch_size_schedule(minibatch_size), progress_printer = progress_writers, checkpoint_frequency = epoch_size, checkpoint_filename = os.path.join(model_path, "ConvNet_CIFAR10_DataAug"), # save_all_checkpoints = False, progress_frequency=epoch_size, cv_source = test_source, cv_mb_size_schedule=cntk.minibatch_size_schedule(minibatch_size), # cv_frequency = epoch_size, restore=restore) # Train all minibatches if profiling: cntk.start_profiler(sync_gpu=True) training_session.train() if profiling: cntk.stop_profiler()
def train_and_test(network, trainer, train_source, test_source, minibatch_size, epoch_size, restore, profiling=False): # define mapping from intput streams to network inputs input_map = { network['feature']: train_source.streams.features, network['label']: train_source.streams.labels } # Train all minibatches if profiling: cntk.start_profiler(sync_gpu=True) training_session( trainer=trainer, mb_source = train_source, var_to_stream = input_map, mb_size = minibatch_size, progress_frequency=epoch_size, checkpoint_config = CheckpointConfig(frequency = epoch_size, filename = os.path.join(model_path, "ConvNet_CIFAR10_DataAug"), restore = restore), cv_config = CrossValidationConfig(source = test_source, mb_size=minibatch_size) ).train() if profiling: cntk.stop_profiler()