From 2df2ce70221e29ad1e55de7103aa2c9240f395d9 Mon Sep 17 00:00:00 2001 From: tqchen Date: Tue, 29 Sep 2015 22:11:43 -0700 Subject: [PATCH] [EXAMPLE] make example run on any folder --- example/cifar10/cifar10.py | 7 +++++-- example/mnist/data.py | 6 ++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/example/cifar10/cifar10.py b/example/cifar10/cifar10.py index 72243e3a68f3..f6dac2c14a31 100644 --- a/example/cifar10/cifar10.py +++ b/example/cifar10/cifar10.py @@ -1,10 +1,13 @@ # pylint: skip-file import sys, os -import mxnet as mx -sys.path.append("../../tests/python/common") +# code to automatically download dataset +curr_path = os.path.dirname(os.path.abspath(os.path.expanduser(__file__))) +sys.path.append(os.path.join(curr_path, "../../tests/python/common")) import get_data +import mxnet as mx import numpy as np import logging + logger = logging.getLogger() logger.setLevel(logging.DEBUG) diff --git a/example/mnist/data.py b/example/mnist/data.py index 38f71263ea3f..d39821f52145 100644 --- a/example/mnist/data.py +++ b/example/mnist/data.py @@ -1,8 +1,10 @@ # pylint: skip-file """ data iterator for mnist """ import sys -sys.path.insert(0, "../../python/") -sys.path.append("../../tests/python/common") +import os +# code to automatically download dataset +curr_path = os.path.dirname(os.path.abspath(os.path.expanduser(__file__))) +sys.path.append(os.path.join(curr_path, "../../tests/python/common")) import get_data import mxnet as mx