From 8dcfdd12567b4dfada1256b8cb0d8e6a496a5171 Mon Sep 17 00:00:00 2001 From: Mark Hillebrand Date: Wed, 26 Oct 2016 12:26:16 +0200 Subject: [PATCH] bindings/python/examples: use relative paths wrt. __file__, not current directory --- .../python/examples/Distributed/CifarResNet_Distributed.py | 3 ++- bindings/python/examples/test/cifar_resnet_test.py | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/bindings/python/examples/Distributed/CifarResNet_Distributed.py b/bindings/python/examples/Distributed/CifarResNet_Distributed.py index a1e6831da..3e5e55526 100644 --- a/bindings/python/examples/Distributed/CifarResNet_Distributed.py +++ b/bindings/python/examples/Distributed/CifarResNet_Distributed.py @@ -129,6 +129,7 @@ def cifar_resnet(data_path, run_test, num_epochs, communicator=None, save_model_ if __name__ == '__main__': data_path = os.path.abspath(os.path.normpath(os.path.join( + os.path.dirname(os.path.abspath(__file__)), *"../../../../Examples/Image/DataSets/CIFAR-10/".split("/")))) os.chdir(data_path) @@ -161,4 +162,4 @@ if __name__ == '__main__': print("Error: %f" % error) - distributed.communicator.finalize() \ No newline at end of file + distributed.communicator.finalize() diff --git a/bindings/python/examples/test/cifar_resnet_test.py b/bindings/python/examples/test/cifar_resnet_test.py index e7f8962c2..c4c64606a 100644 --- a/bindings/python/examples/test/cifar_resnet_test.py +++ b/bindings/python/examples/test/cifar_resnet_test.py @@ -25,9 +25,11 @@ def test_cifar_resnet_error(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( - *"../../../../Examples/Image/DataSets/CIFAR-10/cifar-10-batches-py".split("/")) + 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, '..'))