Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation Fix - Ragged Tensor #2302

Merged
merged 3 commits into from
Aug 26, 2024
Merged
Changes from 1 commit
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
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:"
MarkDaoust marked this conversation as resolved.
Show resolved Hide resolved
]
},
{
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
Loading