def run_cifar_convnet_distributed(): try: base_path = os.path.join(os.environ['CNTK_EXTERNAL_TESTDATA_SOURCE_DIRECTORY'], *"Image/CIFAR/v0/cifar-10-batches-py".split("/")) # N.B. CNTK_EXTERNAL_TESTDATA_SOURCE_DIRECTORY has {train,test}_map.txt # and CIFAR-10_mean.xml in the base_path. except KeyError: base_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), *"../../../../Examples/Image/DataSets/CIFAR-10".split("/")) base_path = os.path.normpath(base_path) os.chdir(os.path.join(base_path, '..')) from _cntk_py import set_computation_network_trace_level, set_fixed_random_seed, force_deterministic_algorithms set_computation_network_trace_level(1) set_fixed_random_seed(1) # BUGBUG: has no effect at present # TODO: remove debugging facilities once this all works #force_deterministic_algorithms() # TODO: do the above; they lead to slightly different results, so not doing it for now train_data = os.path.join(base_path, 'train_map.txt') mean_data = os.path.join(base_path, 'CIFAR-10_mean.xml') test_data = os.path.join(base_path, 'test_map.txt') num_quantization_bits = 32 return convnet_cifar10_dataaug(train_data, test_data, mean_data, num_quantization_bits, epoch_size=512, max_epochs=2)
def run_cifar_convnet_distributed(): try: base_path = os.path.join(os.environ['CNTK_EXTERNAL_TESTDATA_SOURCE_DIRECTORY'], *"Image/CIFAR/v0/cifar-10-batches-py".split("/")) # N.B. CNTK_EXTERNAL_TESTDATA_SOURCE_DIRECTORY has {train,test}_map.txt # and CIFAR-10_mean.xml in the base_path. except KeyError: base_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), *"../../../../Examples/Image/DataSets/CIFAR-10".split("/")) base_path = os.path.normpath(base_path) os.chdir(os.path.join(base_path, '..')) from _cntk_py import set_computation_network_trace_level, set_fixed_random_seed, force_deterministic_algorithms set_computation_network_trace_level(1) set_fixed_random_seed(1) # BUGBUG: has no effect at present # TODO: remove debugging facilities once this all works #force_deterministic_algorithms() # TODO: do the above; they lead to slightly different results, so not doing it for now create_train_reader = lambda data_size: create_reader(os.path.join(base_path, 'train_map.txt'), os.path.join(base_path, 'CIFAR-10_mean.xml'), True, data_size, 0) test_reader = create_reader(os.path.join(base_path, 'test_map.txt'), os.path.join(base_path, 'CIFAR-10_mean.xml'), False, FULL_DATA_SWEEP) distributed_after_samples = 0 num_quantization_bits = 32 create_dist_learner = lambda learner: distributed.data_parallel_distributed_learner( learner=learner, num_quantization_bits=num_quantization_bits, distributed_after=distributed_after_samples) return convnet_cifar10_dataaug(create_train_reader, test_reader, create_dist_learner, max_epochs=1, num_mbs_per_log=None)
def test_cifar_convnet_error(device_id): if platform.system() == 'Windows': pytest.skip('test skipped on Windows') set_default_device(cntk_device(device_id)) try: base_path = os.path.join( os.environ['CNTK_EXTERNAL_TESTDATA_SOURCE_DIRECTORY'], *"Image/CIFAR/v0/cifar-10-batches-py".split("/")) # N.B. CNTK_EXTERNAL_TESTDATA_SOURCE_DIRECTORY has {train,test}_map.txt # and CIFAR-10_mean.xml in the base_path. except KeyError: base_path = os.path.join( os.path.dirname(os.path.abspath(__file__)), *"../../../../Examples/Image/DataSets/CIFAR-10".split("/")) base_path = os.path.normpath(base_path) os.chdir(os.path.join(base_path, '..')) from _cntk_py import set_computation_network_trace_level, set_fixed_random_seed, force_deterministic_algorithms set_computation_network_trace_level(1) set_fixed_random_seed( 1 ) # BUGBUG: has no effect at present # TODO: remove debugging facilities once this all works #force_deterministic_algorithms() # TODO: do the above; they lead to slightly different results, so not doing it for now reader_train = create_reader(os.path.join(base_path, 'train_map.txt'), os.path.join(base_path, 'CIFAR-10_mean.xml'), True, 0) reader_test = create_reader(os.path.join(base_path, 'test_map.txt'), os.path.join(base_path, 'CIFAR-10_mean.xml'), False) distributed_after_samples = 0 num_quantization_bits = 32 distributed_trainer = distributed.data_parallel_distributed_trainer( num_quantization_bits=num_quantization_bits, distributed_after=distributed_after_samples) test_error = convnet_cifar10_dataaug(reader_train, reader_test, distributed_trainer, max_epochs=1) expected_test_error = 0.617 assert np.allclose(test_error, expected_test_error, atol=TOLERANCE_ABSOLUTE)
def run_cifar_convnet_distributed(): try: base_path = os.path.join( os.environ['CNTK_EXTERNAL_TESTDATA_SOURCE_DIRECTORY'], *"Image/CIFAR/v0/cifar-10-batches-py".split("/")) # N.B. CNTK_EXTERNAL_TESTDATA_SOURCE_DIRECTORY has {train,test}_map.txt # and CIFAR-10_mean.xml in the base_path. except KeyError: base_path = os.path.join( os.path.dirname(os.path.abspath(__file__)), *"../../../../Examples/Image/DataSets/CIFAR-10".split("/")) base_path = os.path.normpath(base_path) os.chdir(os.path.join(base_path, '..')) from _cntk_py import set_computation_network_trace_level, set_fixed_random_seed, force_deterministic_algorithms set_computation_network_trace_level(1) set_fixed_random_seed( 1 ) # BUGBUG: has no effect at present # TODO: remove debugging facilities once this all works #force_deterministic_algorithms() # TODO: do the above; they lead to slightly different results, so not doing it for now create_train_reader = lambda data_size: create_reader( os.path.join(base_path, 'train_map.txt'), os.path.join(base_path, 'CIFAR-10_mean.xml'), True, data_size, 0) test_reader = create_reader(os.path.join(base_path, 'test_map.txt'), os.path.join(base_path, 'CIFAR-10_mean.xml'), False, FULL_DATA_SWEEP) distributed_after_samples = 0 num_quantization_bits = 32 create_dist_learner = lambda learner: distributed.data_parallel_distributed_learner( learner=learner, num_quantization_bits=num_quantization_bits, distributed_after=distributed_after_samples) return convnet_cifar10_dataaug(create_train_reader, test_reader, create_dist_learner, max_epochs=1, num_mbs_per_log=None)
def run_cifar_convnet_distributed(): base_path = prepare_CIFAR10_data() # change dir to locate data.zip correctly os.chdir(base_path) from _cntk_py import set_computation_network_trace_level, set_fixed_random_seed, force_deterministic_algorithms set_computation_network_trace_level(1) set_fixed_random_seed( 1 ) # BUGBUG: has no effect at present # TODO: remove debugging facilities once this all works #force_deterministic_algorithms() # TODO: do the above; they lead to slightly different results, so not doing it for now train_data = os.path.join(base_path, 'train_map.txt') mean_data = os.path.join(base_path, 'CIFAR-10_mean.xml') test_data = os.path.join(base_path, 'test_map.txt') num_quantization_bits = 32 return convnet_cifar10_dataaug(train_data, test_data, mean_data, num_quantization_bits, epoch_size=512, max_epochs=2)