diff options
author | Vijay Vasudevan <vrv@google.com> | 2016-03-29 18:23:11 -0800 |
---|---|---|
committer | TensorFlower Gardener <gardener@tensorflow.org> | 2016-03-29 19:33:33 -0700 |
commit | 80a5a3e653f3b10e2680fe2ea9bc511e8801e273 (patch) | |
tree | 6d205c779cde774c46e6aa328a8f7ef0f85a1461 /tensorflow/examples/udacity | |
parent | e3a0d6fb61cbb1dd9864684c20e49ef3fa385bb6 (diff) |
Merge changes from github.
Change: 118532471
Diffstat (limited to 'tensorflow/examples/udacity')
-rw-r--r-- | tensorflow/examples/udacity/1_notmnist.ipynb | 11 | ||||
-rw-r--r-- | tensorflow/examples/udacity/2_fullyconnected.ipynb | 4 | ||||
-rw-r--r-- | tensorflow/examples/udacity/5_word2vec.ipynb | 5 |
3 files changed, 11 insertions, 9 deletions
diff --git a/tensorflow/examples/udacity/1_notmnist.ipynb b/tensorflow/examples/udacity/1_notmnist.ipynb index 9d864ccd37..2265445815 100644 --- a/tensorflow/examples/udacity/1_notmnist.ipynb +++ b/tensorflow/examples/udacity/1_notmnist.ipynb @@ -55,7 +55,10 @@ "from scipy import ndimage\n", "from sklearn.linear_model import LogisticRegression\n", "from six.moves.urllib.request import urlretrieve\n", - "from six.moves import cPickle as pickle" + "from six.moves import cPickle as pickle\n", + "\n", + "# Config the matlotlib backend as plotting inline in IPython\n", + "%matplotlib inline" ], "outputs": [], "execution_count": 0 @@ -295,9 +298,8 @@ " image_files = os.listdir(folder)\n", " dataset = np.ndarray(shape=(len(image_files), image_size, image_size),\n", " dtype=np.float32)\n", - " image_index = 0\n", " print(folder)\n", - " for image in os.listdir(folder):\n", + " for image_index, image in enumerate(image_files):\n", " image_file = os.path.join(folder, image)\n", " try:\n", " image_data = (ndimage.imread(image_file).astype(float) - \n", @@ -305,11 +307,10 @@ " if image_data.shape != (image_size, image_size):\n", " raise Exception('Unexpected image shape: %s' % str(image_data.shape))\n", " dataset[image_index, :, :] = image_data\n", - " image_index += 1\n", " except IOError as e:\n", " print('Could not read:', image_file, ':', e, '- it\\'s ok, skipping.')\n", " \n", - " num_images = image_index\n", + " num_images = image_index + 1\n", " dataset = dataset[0:num_images, :, :]\n", " if num_images < min_num_images:\n", " raise Exception('Many fewer images than expected: %d < %d' %\n", diff --git a/tensorflow/examples/udacity/2_fullyconnected.ipynb b/tensorflow/examples/udacity/2_fullyconnected.ipynb index c8815f631b..588b581a69 100644 --- a/tensorflow/examples/udacity/2_fullyconnected.ipynb +++ b/tensorflow/examples/udacity/2_fullyconnected.ipynb @@ -410,7 +410,7 @@ "source": [ "Let's now switch to stochastic gradient descent training instead, which is much faster.\n", "\n", - "The graph will be similar, except that instead of holding all the training data into a constant node, we create a `Placeholder` node which will be fed actual data at every call of `sesion.run()`." + "The graph will be similar, except that instead of holding all the training data into a constant node, we create a `Placeholder` node which will be fed actual data at every call of `session.run()`." ] }, { @@ -577,7 +577,7 @@ "Problem\n", "-------\n", "\n", - "Turn the logistic regression example with SGD into a 1-hidden layer neural network with rectified linear units (nn.relu()) and 1024 hidden nodes. This model should improve your validation / test accuracy.\n", + "Turn the logistic regression example with SGD into a 1-hidden layer neural network with rectified linear units [nn.relu()](https://www.tensorflow.org/versions/r0.7/api_docs/python/nn.html#relu) and 1024 hidden nodes. This model should improve your validation / test accuracy.\n", "\n", "---" ] diff --git a/tensorflow/examples/udacity/5_word2vec.ipynb b/tensorflow/examples/udacity/5_word2vec.ipynb index 94ba37ee13..62dbec4e11 100644 --- a/tensorflow/examples/udacity/5_word2vec.ipynb +++ b/tensorflow/examples/udacity/5_word2vec.ipynb @@ -43,6 +43,7 @@ "source": [ "# These are all the modules we'll be using later. Make sure you can import them\n", "# before proceeding further.\n", + "%matplotlib inline\n", "from __future__ import print_function\n", "import collections\n", "import math\n", @@ -521,12 +522,12 @@ " # note that this is expensive (~20% slowdown if computed every 500 steps)\n", " if step % 10000 == 0:\n", " sim = similarity.eval()\n", - " for i in xrange(valid_size):\n", + " for i in range(valid_size):\n", " valid_word = reverse_dictionary[valid_examples[i]]\n", " top_k = 8 # number of nearest neighbors\n", " nearest = (-sim[i, :]).argsort()[1:top_k+1]\n", " log = 'Nearest to %s:' % valid_word\n", - " for k in xrange(top_k):\n", + " for k in range(top_k):\n", " close_word = reverse_dictionary[nearest[k]]\n", " log = '%s %s,' % (log, close_word)\n", " print(log)\n", |