|
66 | 66 | },
|
67 | 67 | {
|
68 | 68 | "cell_type": "code",
|
69 |
| - "execution_count": 2, |
| 69 | + "execution_count": null, |
70 | 70 | "metadata": {},
|
71 | 71 | "outputs": [],
|
72 | 72 | "source": [
|
|
101 | 101 | "import numpy as np\n",
|
102 | 102 | "import time\n",
|
103 | 103 | "import functools\n",
|
| 104 | + "from six.moves import xrange # pylint: disable=redefined-builtin\n", |
104 | 105 | "\n",
|
105 | 106 | "import tensorflow as tf\n",
|
106 | 107 | "\n",
|
|
1066 | 1067 | }
|
1067 | 1068 | ],
|
1068 | 1069 | "source": [
|
| 1070 | + "def _get_next(iterable):\n", |
| 1071 | + " try:\n", |
| 1072 | + " return iterable.next() # Python 2.x.x\n", |
| 1073 | + " except AttributeError:\n", |
| 1074 | + " return iterable.__next__() # Python 3.x.x\n", |
| 1075 | + "\n", |
1069 | 1076 | "# Run inference.\n",
|
1070 | 1077 | "predict_input_fn = _get_predict_input_fn(36, NOISE_DIMS)\n",
|
1071 | 1078 | "prediction_iterable = gan_estimator.predict(\n",
|
1072 | 1079 | " predict_input_fn, hooks=[tf.train.StopAtStepHook(last_step=1)])\n",
|
1073 |
| - "predictions = [prediction_iterable.next() for _ in xrange(36)]\n", |
| 1080 | + "predictions = [_get_next(prediction_iterable) for _ in xrange(36)]\n", |
1074 | 1081 | "\n",
|
1075 | 1082 | "try: # Close the predict session.\n",
|
1076 |
| - " prediction_iterable.next()\n", |
| 1083 | + " _get_next(prediction_iterable)\n", |
1077 | 1084 | "except StopIteration:\n",
|
1078 | 1085 | " pass\n",
|
1079 | 1086 | "\n",
|
|
1889 | 1896 | "assert images_to_eval % cat_dim == 0\n",
|
1890 | 1897 | "\n",
|
1891 | 1898 | "unstructured_inputs = tf.random_normal([images_to_eval, noise_dims-cont_dim])\n",
|
1892 |
| - "cat_noise = tf.constant(range(cat_dim) * (images_to_eval // cat_dim))\n", |
| 1899 | + "cat_noise = tf.constant(list(range(cat_dim)) * (images_to_eval // cat_dim))\n", |
1893 | 1900 | "cont_noise = tf.random_uniform([images_to_eval, cont_dim], -1.0, 1.0)\n",
|
1894 | 1901 | "\n",
|
1895 | 1902 | "with tf.variable_scope(infogan_model.generator_scope, reuse=True):\n",
|
|
0 commit comments