Correctly check shape not None in Keras add_weight
.
When calling Keras add_weight with a np list, as written the `shape or ()` "trick" results in the following exception: """ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()""" This change fixes the problem by using an explicit `if`. PiperOrigin-RevId: 236407103
This commit is contained in:
parent
fc33a70c90
commit
ebeb598c2d
@ -310,7 +310,8 @@ class Layer(trackable.Trackable):
|
|||||||
ValueError: When giving unsupported dtype and no initializer or when
|
ValueError: When giving unsupported dtype and no initializer or when
|
||||||
trainable has been set to True with synchronization set as `ON_READ`.
|
trainable has been set to True with synchronization set as `ON_READ`.
|
||||||
"""
|
"""
|
||||||
shape = shape or ()
|
if shape is None:
|
||||||
|
shape = ()
|
||||||
# Validate optional keyword arguments.
|
# Validate optional keyword arguments.
|
||||||
for kwarg in kwargs:
|
for kwarg in kwargs:
|
||||||
if kwarg not in ['getter', 'collections', 'experimental_autocast']:
|
if kwarg not in ['getter', 'collections', 'experimental_autocast']:
|
||||||
|
Loading…
Reference in New Issue
Block a user