keras-io icon indicating copy to clipboard operation
keras-io copied to clipboard

Broken rendering output for IntegerLookup page

Open mbrukman opened this issue 3 years ago • 2 comments
trafficstars

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()`.

mbrukman avatar May 14 '22 22:05 mbrukman

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 avatar May 17 '22 17:05 mattdangerw

Assigning myself to take a closer look.

mattdangerw avatar May 17 '22 21:05 mattdangerw

@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 avatar Nov 07 '23 23:11 sachinprasadhs

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

pcoet avatar Nov 08 '23 02:11 pcoet

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

image

sachinprasadhs avatar Feb 14 '24 22:02 sachinprasadhs

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[bot] avatar Feb 29 '24 01:02 github-actions[bot]

Thank you for fixing this, @mattdangerw! 👍

mbrukman avatar Mar 06 '24 02:03 mbrukman

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

github-actions[bot] avatar Mar 06 '24 02:03 github-actions[bot]