Fix IndexError in text generation tutorial
Keras now wants normal Python tuples rather than Batch objects
},
"outputs": [],
"source": [
- "# Using a namedtuple with keys x and y as the output type of the\n",
- "# dataset keeps both TFF and Keras happy:\n",
- "BatchType = collections.namedtuple('BatchType', ['x', 'y'])\n",
- "\n",
"# Construct a lookup table to map string chars to indexes,\n",
"# using the vocab loaded above:\n",
"table = tf.lookup.StaticHashTable(\n",
"def split_input_target(chunk):\n",
" input_text = tf.map_fn(lambda x: x[:-1], chunk)\n",
" target_text = tf.map_fn(lambda x: x[1:], chunk)\n",
- " return BatchType(input_text, target_text)\n",
+ " return (input_text, target_text)\n",
"\n",
"\n",
"def preprocess(dataset):\n",
