Skip to content

Commit 45b46d2

Browse files
authored
Convert to absolute path
Sometimes `os.path.dirname(__file__)` returns empty and it makes `dataset_dir` empty. This causes a permission error for most of uses because `save_file` will be created at root path. To avoid this, we have to convert current file path as absolute path then take its parent directory path.
1 parent 952e83c commit 45b46d2

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

dataset/mnist.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
'test_label':'t10k-labels-idx1-ubyte.gz'
1919
}
2020

21-
dataset_dir = os.path.dirname(__file__)
21+
dataset_dir = os.path.dirname(os.path.abspath(__file__))
2222
save_file = dataset_dir + "/mnist.pkl"
2323

2424
train_num = 60000

0 commit comments

Comments
 (0)