bindings/python/examples: use relative paths wrt. __file__, not current directory

This commit is contained in:
Mark Hillebrand 2016-10-26 12:26:16 +02:00
Родитель d424bba2c5
Коммит 8dcfdd1256
2 изменённых файлов: 6 добавлений и 3 удалений

Просмотреть файл

@ -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()
distributed.communicator.finalize()

Просмотреть файл

@ -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, '..'))