Skip to content

Commit

Permalink
Documentation Fix - Ragged Tensor
Browse files Browse the repository at this point in the history
  • Loading branch information
balaganesh102004 authored Apr 11, 2024
1 parent ec3a1b3 commit f2c7ee7
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions site/en/guide/ragged_tensor.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -674,7 +674,7 @@
"source": [
"### Keras\n",
"\n",
"[tf.keras](https://www.tensorflow.org/guide/keras) is TensorFlow's high-level API for building and training deep learning models. Ragged tensors may be passed as inputs to a Keras model by setting `ragged=True` on `tf.keras.Input` or `tf.keras.layers.InputLayer`. Ragged tensors may also be passed between Keras layers, and returned by Keras models. The following example shows a toy LSTM model that is trained using ragged tensors."
"[tf.keras](https://www.tensorflow.org/guide/keras) is TensorFlow's high-level API for building and training deep learning models. Ragged tensors can be passed as inputs to a Keras model by using ragged tensors between Keras layers, and returning ragged tensors by Keras models. The following example shows a toy LSTM model that is trained using ragged tensors:"
]
},
{
Expand All @@ -700,17 +700,17 @@
"\n",
"# Build the Keras model.\n",
"keras_model = tf.keras.Sequential([\n",
" tf.keras.layers.Input(shape=[None], dtype=tf.int64, ragged=True),\n",
" tf.keras.layers.Embedding(hash_buckets, 16),\n",
" tf.keras.layers.LSTM(32, use_bias=False),\n",
" tf.keras.layers.Embedding(hash_buckets, 16, input_length=hashed_words.shape[1]),\n",
" tf.keras.layers.LSTM(32, return_sequences=True, use_bias=False),\n",
" tf.keras.layers.Flatten(),\n",
" tf.keras.layers.Dense(32),\n",
" tf.keras.layers.Activation(tf.nn.relu),\n",
" tf.keras.layers.Dense(1)\n",
"])\n",
"\n",
"keras_model.compile(loss='binary_crossentropy', optimizer='rmsprop')\n",
"keras_model.fit(hashed_words, is_question, epochs=5)\n",
"print(keras_model.predict(hashed_words))"
"print(keras_model.predict(hashed_words))\n"
]
},
{
Expand Down

0 comments on commit f2c7ee7

Please sign in to comment.