Skip to content

Commit

Permalink
Squashed commit of the following:
Browse files Browse the repository at this point in the history
commit 4e7b6e2
Merge: b0b231a 2b7d622
Author: Christian Jauvin <[email protected]>
Date:   Sat Jan 30 13:11:00 2016 -0500

    Merge branch 'master' into fix/udacity-notebooks-py3

commit b0b231a
Author: Christian Jauvin <[email protected]>
Date:   Sat Jan 30 12:57:32 2016 -0500

    More explicit examples of batch generation algo
  • Loading branch information
vincentvanhoucke committed Jan 30, 2016
1 parent 2b7d622 commit 88507bc
Showing 1 changed file with 23 additions and 27 deletions.
50 changes: 23 additions & 27 deletions tensorflow/examples/udacity/5_word2vec.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -354,35 +354,31 @@
" data_index = (data_index + 1) % len(data)\n",
" return batch, labels\n",
"\n",
"batch, labels = generate_batch(batch_size=8, num_skips=2, skip_window=1)\n",
"for i in range(8):\n",
" print('%d -> %d' % (batch[i], labels[i, 0]))\n",
" print('%s -> %s' % (reverse_dictionary[batch[i]],\n",
" reverse_dictionary[labels[i, 0]]))"
"print('data:', [reverse_dictionary[di] for di in data[:8]])\n",
"\n",
"for num_skips, skip_window in [(2, 1), (4, 2)]:\n",
" data_index = 0\n",
" batch, labels = generate_batch(batch_size=8, num_skips=num_skips, skip_window=skip_window)\n",
" print('\\nwith num_skips = %d and skip_window = %d:' % (num_skips, skip_window))\n",
" print(' batch:', [reverse_dictionary[bi] for bi in batch])\n",
" print(' labels:', [reverse_dictionary[li] for li in labels.reshape(8)])"
],
"outputs": [
{
"output_type": "stream",
"text": [
" 3083 -> 5243\n",
"originated -> anarchism\n",
"3083 -> 12\n",
"originated -> as\n",
"12 -> 3083\n",
"as -> originated\n",
"12 -> 6\n",
"as -> a\n",
"6 -> 12\n",
"a -> as\n",
"6 -> 195\n",
"a -> term\n",
"195 -> 6\n",
"term -> a\n",
"195 -> 2\n",
"term -> of\n"
],
"name": "stdout"
}
{
"name": "stdout",
"output_type": "stream",
"text": [
"data: ['anarchism', 'originated', 'as', 'a', 'term', 'of', 'abuse', 'first']\n",
"\n",
"with num_skips = 2 and skip_window = 1:\n",
" batch: ['originated', 'originated', 'as', 'as', 'a', 'a', 'term', 'term']\n",
" labels: ['as', 'anarchism', 'a', 'originated', 'term', 'as', 'a', 'of']\n",
"\n",
"with num_skips = 4 and skip_window = 2:\n",
" batch: ['as', 'as', 'as', 'as', 'a', 'a', 'a', 'a']\n",
" labels: ['anarchism', 'originated', 'term', 'a', 'as', 'of', 'originated', 'term']\n"
]
}
],
"execution_count": 0
},
Expand Down

0 comments on commit 88507bc

Please sign in to comment.