Skip to content

About keras mask layers #143367

Discussion options

You must be logged in to vote

The error you’re seeing, ValueError: Exception encountered when calling BroadcastTo.call(), usually happens because there’s a mismatch in shapes or an issue with how Keras layers handle masking. The key issue is in using mask_zero=True in the Embedding layer. This mask_zero=True argument is supposed to mask out padding tokens, but it sometimes doesn't work well when passed through certain layers like Concatenate and LSTM.

Here’s the solution and reasoning to address this problem clearly:

Solution

  1. Remove mask_zero=True from the Embedding layers.
    Masking with mask_zero=True in Embedding layers can lead to issues when concatenating embeddings or passing them to certain layers that don't su…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@xiaohua6689
Comment options

Answer selected by xiaohua6689
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Programming Help Programming languages, open source, and software development.
2 participants