Skip to content

[Bug] keras Add layer failing to build #19810

Closed
@qzhang-nuro

Description

@qzhang-nuro

Keras Version: 3.3.3

Example code:

import keras
add_layer = keras.layers.Add()
symbolic_a = keras.layers.Input(shape=(32,))
symbolic_b = keras.layers.Input(shape=(32,))
add_layer([symbolic_a, symbolic_b])

Error trace:

  File "...keras/keras/src/layers/merging/base_merge.py", line 65, in build
    if not isinstance(input_shape[0], (tuple, list)):
TypeError: 'NoneType' object is not subscriptable

Possible root cause:
layer input is a list. is_nested does not return True for a list therefore the Callspec tensor_arg_dict is empty, and add's build gets a None as its input_shape argument

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions