I ran this code on my machine using Jupyter Notebook, thinking it may not work since the relative directory doesn't exist...However, it turns out it worked. So the relative directory used /datasets/ud730/mnist
must be relative to current working dir which is C:\\Users\\george.liu\\OneDrive\\WorkingDir\\Temp
. However, I was not able to find any related folders or files. I also checked C:\\Users\\george.liu
, nothing there either...What am I missing? Where does the file go? Thanks!
from tensorflow.examples.tutorials.mnist import input_data
import tensorflow as tf
n_input = 784 # MNIST data input (img shape: 28*28)
n_classes = 10 # MNIST total classes (0-9 digits)
# Import MNIST data
mnist = input_data.read_data_sets('/datasets/ud730/mnist', one_hot=True)
# The features are already scaled and the data is shuffled
train_features = mnist.train.images
test_features = mnist.test.images
train_labels = mnist.train.labels.astype(np.float32)
test_labels = mnist.test.labels.astype(np.float32)
# Weights & bias
weights = tf.Variable(tf.random_normal([n_input, n_classes]))
bias = tf.Variable(tf.random_normal([n_classes]))
EDIT:
I did check current working dir using this code:
import os
os.getcwd()
and this is the result:
'C:\Users\george.liu\OneDrive\WorkingDir\Temp'
On Linux /datasets/
is an absolute path
But on Windows machine, if you have a subdirectory python
in your current drive, ex D:\python
and the current directory is somewhere in D:
(not necessarily at root, could be: D:\python
already) you can do os.chdir("/python")
and it works like if you did os.chdir(r"D:\python")
So the slash is not ignored, it's just like :\
(root of current drive)
In your case, python looks for C:\datasets\ud730\mnist
since the current directory is somewhere on drive C:
.
You can check that by printing os.path.abspath('/datasets/ud730/mnist')