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

Broken rendering output for IntegerLookup page #874

Closed
mbrukman opened this issue May 14, 2022 · 8 comments · Fixed by #1606
Closed

Broken rendering output for IntegerLookup page #874

mbrukman opened this issue May 14, 2022 · 8 comments · Fixed by #1606

Comments

@mbrukman
Copy link
Contributor

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

IntegerLookup docs screenshot

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()`.
@mattdangerw
Copy link
Member

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.

@mattdangerw
Copy link
Member

Assigning myself to take a closer look.

@sachinprasadhs sachinprasadhs self-assigned this Nov 7, 2023
@sachinprasadhs
Copy link
Collaborator

@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

"path": "integer_lookup",
"title": "IntegerLookup layer",
"generate": ["keras_core.layers.IntegerLookup"],

@pcoet
Copy link
Collaborator

pcoet commented Nov 8, 2023

@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.

@sachinprasadhs
Copy link
Collaborator

The rendering issue is fixed with the above linked PR, you can refer the below screenshot and close the issue.

image

Copy link

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.

@github-actions github-actions bot added the stale label Feb 29, 2024
@mbrukman
Copy link
Contributor Author

mbrukman commented Mar 6, 2024

Thank you for fixing this, @mattdangerw! 👍

@mbrukman mbrukman closed this as completed Mar 6, 2024
Copy link

github-actions bot commented Mar 6, 2024

Are you satisfied with the resolution of your issue?
Yes
No

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants