-
Notifications
You must be signed in to change notification settings - Fork 19.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
keras.Sequential
sometimes states misleading reason for failing to construct model
#19701
Comments
Thanks for the report, do you have a code snippet to reproduce the problem as stated in the title? |
See the following colab: The call function signatures are direct implementations of the side effect cases mentioned above. |
keras.Sequential.build()
builds by running a placeholder tensor through each given layer to build aFunctional
model.The method explicitly handles two types of exceptions:
NotImplementedError
andTypeError
, of which the latter is intercepted in order to reraise aValueError
in the case of parameter incompatibility.However, the mechanism to check whether the layer's
call()
method is compatible with theSequential
API currently assumes any argument without a default value is a positional argument, presenting some unintended side effects:call()
method with default values for all parameters will be reported to have no positional argumentscall()
method with a single keyword-only parameter without a default value will not be detected as erroneous.*args
or**kwargs
parameters will be included as positional arguments, whether or not they are required for the layer to runWhile there is no sane way to detect whether a layer with variable arguments is properly defined, the other issues may be avoided by checking the
kind
field of each parameter along with the existence of a default value.I might've missed some possible cases; feedback would be appreciated.
The text was updated successfully, but these errors were encountered: