Skip to content

hasattr() raising ValueError when used with input and output attributes of a keras layer #20155

Closed
@Doch88

Description

@Doch88

The description is self-explanatory, when using hasattr() on the input attribute of a keras layer it raises an error when the layer has not been called yet.

    if hasattr(first_layer, 'input'):
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: The layer resizing has never been called and thus has no defined input.

This happens because "input" and "output" raise a ValueError, instead of a AttributeError as it should be.

Metadata

Metadata

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