keras-io
keras-io copied to clipboard
Broken rendering output for IntegerLookup page
Problem statement
The bottom of this page: https://keras.io/api/layers/preprocessing_layers/categorical/integer_lookup/ looks incorrect (screenshot below) which seems to imply that the input source code may have incorrect syntax, but that seems to be correct (source, snippet included inline below).
Potential resolution
Perhaps that page needs to be re-generated and uploaded to the website to fix the rendering issue?
Screenshot of broken rendering on the page

Source documentation in code
**Forward and inverse lookup pairs**
This example demonstrates how to use the vocabulary of a standard lookup
layer to create an inverse lookup layer.
>>> vocab = [12, 36, 1138, 42]
>>> data = tf.constant([[12, 1138, 42], [42, 1000, 36]])
>>> layer = tf.keras.layers.IntegerLookup(vocabulary=vocab)
>>> i_layer = tf.keras.layers.IntegerLookup(
... vocabulary=layer.get_vocabulary(), invert=True)
>>> int_data = layer(data)
>>> i_layer(int_data)
<tf.Tensor: shape=(2, 3), dtype=int64, numpy=
array([[ 12, 1138, 42],
[ 42, -1, 36]])>
In this example, the input token 1000 resulted in an output of -1, since
1000 was not in the vocabulary - it got represented as an OOV, and all OOV
tokens are returned as -1 in the inverse layer. Also, note that for the
inverse to work, you must have already set the forward layer vocabulary
either directly or via `adapt()` before calling `get_vocabulary()`.
I've actually noticed this too for some docs symbols we are about to push out. It seems to happen always after the 10th >>> style code block. I think this might be somewhere we are doing string replacing with an index, and don't accommodate the index being two digits long.
You can actually see a trailing 0 after the second triple backtick that is messing up rendering. If you remove that from the source markdown, things are fine.
Assigning myself to take a closer look.
@MarkDaoust , @pcoet , How can we re-generate the doc from the original file, I see a different content and it is still not rendering new content in the website. https://github.com/keras-team/keras/blob/master/keras/layers/preprocessing/integer_lookup.py https://github.com/keras-team/keras-io/blob/472f9b98c06b3425814b8ce242233d5e7ca5cd1b/scripts/keras_core_api_master.py#L447-L449
@sachinprasadhs I don't know how to regenerate an API doc, unfortunately. I checked in the autogen script (https://github.com/keras-team/keras-io/blob/master/scripts/autogen.py), but it looks like that only handles guides and examples. I'd guess the rendering issue is still outstanding, though.
The rendering issue is fixed with the above linked PR, you can refer the below screenshot and close the issue.
This issue is stale because it has been open for 14 days with no activity. It will be closed if no further activity occurs. Thank you.
Thank you for fixing this, @mattdangerw! 👍