Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions research/gan/tutorial.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -101,6 +101,7 @@
"import numpy as np\n",
"import time\n",
"import functools\n",
"from six.moves import xrange # pylint: disable=redefined-builtin\n",
"\n",
"import tensorflow as tf\n",
"\n",
Expand Down Expand Up @@ -1066,14 +1067,20 @@
}
],
"source": [
"def _get_next(iterable):\n",
" try:\n",
" return iterable.next() # Python 2.x.x\n",
" except AttributeError:\n",
" return iterable.__next__() # Python 3.x.x\n",
"\n",
"# Run inference.\n",
"predict_input_fn = _get_predict_input_fn(36, NOISE_DIMS)\n",
"prediction_iterable = gan_estimator.predict(\n",
" predict_input_fn, hooks=[tf.train.StopAtStepHook(last_step=1)])\n",
"predictions = [prediction_iterable.next() for _ in xrange(36)]\n",
"predictions = [_get_next(prediction_iterable) for _ in xrange(36)]\n",
"\n",
"try: # Close the predict session.\n",
" prediction_iterable.next()\n",
" _get_next(prediction_iterable)\n",
"except StopIteration:\n",
" pass\n",
"\n",
Expand Down Expand Up @@ -1889,7 +1896,7 @@
"assert images_to_eval % cat_dim == 0\n",
"\n",
"unstructured_inputs = tf.random_normal([images_to_eval, noise_dims-cont_dim])\n",
"cat_noise = tf.constant(range(cat_dim) * (images_to_eval // cat_dim))\n",
"cat_noise = tf.constant(list(range(cat_dim)) * (images_to_eval // cat_dim))\n",
"cont_noise = tf.random_uniform([images_to_eval, cont_dim], -1.0, 1.0)\n",
"\n",
"with tf.variable_scope(infogan_model.generator_scope, reuse=True):\n",
Expand Down