Skip to content

TransformerEncoder layer unable to be saved #1303

@mateuszlugowski

Description

@mateuszlugowski

Describe the bug

Trying to save a model containing TransformerEncoder layer results in an error. This is due to some weights of it having the same exact name, and h5 format is raising a ValueError because of that.

To Reproduce

from keras_nlp.layers import TransformerEncoder

inp = keras.layers.Input((30, 128))
tl = TransformerEncoder(
                intermediate_dim=512,
                num_heads=8,
            )
model = keras.models.Model(inp, tl(inp))
model.save_weights('test.h5')

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions