diff options
author | Derek Murray <mrry@google.com> | 2016-05-23 11:39:39 -0800 |
---|---|---|
committer | TensorFlower Gardener <gardener@tensorflow.org> | 2016-05-23 12:42:36 -0700 |
commit | 892ca4ddc12852a7b4633fd08f163941356cb4e6 (patch) | |
tree | be913f46bb9323685c5a807a89fca6dc52a25504 /tensorflow/examples/udacity | |
parent | 76d90938f95a14a5723c253ec8529e93939a25e2 (diff) |
Merge changes from github.
Change: 123026122
Diffstat (limited to 'tensorflow/examples/udacity')
-rw-r--r-- | tensorflow/examples/udacity/1_notmnist.ipynb | 22 | ||||
-rw-r--r-- | tensorflow/examples/udacity/5_word2vec.ipynb | 5 |
2 files changed, 26 insertions, 1 deletions
diff --git a/tensorflow/examples/udacity/1_notmnist.ipynb b/tensorflow/examples/udacity/1_notmnist.ipynb index 2265445815..32ece419b0 100644 --- a/tensorflow/examples/udacity/1_notmnist.ipynb +++ b/tensorflow/examples/udacity/1_notmnist.ipynb @@ -110,11 +110,31 @@ }, "source": [ "url = 'http://commondatastorage.googleapis.com/books1000/'\n", + "last_percent_reported = None\n", "\n", + "def download_progress_hook(count, blockSize, totalSize):\n", + " \"\"\"A hook to report the progress of a download. This is mostly intended for users with\n", + " slow internet connections. Reports every 1% change in download progress.\n", + " \"\"\"\n", + " global last_percent_reported\n", + " percent = int(count * blockSize * 100 / totalSize)\n", + "\n", + " if last_percent_reported != percent:\n", + " if percent % 5 == 0:\n", + " sys.stdout.write(\"%s%%\" % percent)\n", + " sys.stdout.flush()\n", + " else:\n", + " sys.stdout.write(\".\")\n", + " sys.stdout.flush()\n", + " \n", + " last_percent_reported = percent\n", + " \n", "def maybe_download(filename, expected_bytes, force=False):\n", " \"\"\"Download a file if not present, and make sure it's the right size.\"\"\"\n", " if force or not os.path.exists(filename):\n", - " filename, _ = urlretrieve(url + filename, filename)\n", + " print('Attempting to download:', filename) \n", + " filename, _ = urlretrieve(url + filename, filename, reporthook=download_progress_hook)\n", + " print('\\nDownload Complete!')\n", " statinfo = os.stat(filename)\n", " if statinfo.st_size == expected_bytes:\n", " print('Found and verified', filename)\n", diff --git a/tensorflow/examples/udacity/5_word2vec.ipynb b/tensorflow/examples/udacity/5_word2vec.ipynb index 62dbec4e11..f932f62e28 100644 --- a/tensorflow/examples/udacity/5_word2vec.ipynb +++ b/tensorflow/examples/udacity/5_word2vec.ipynb @@ -446,6 +446,11 @@ " train_labels, num_sampled, vocabulary_size))\n", "\n", " # Optimizer.\n", + " # Note: The optimizer will optimize the softmax_weights AND the embeddings.\n", + " # This is because the embeddings are defined as a variable quantity and the\n", + " # optimizer's `minimize` method will by default modify all variable quantities \n", + " # that contribute to the tensor it is passed.\n", + " # See docs on `tf.train.Optimizer.minimize()` for more details.\n", " optimizer = tf.train.AdagradOptimizer(1.0).minimize(loss)\n", " \n", " # Compute the similarity between minibatch examples and all embeddings.\n", |