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:
Joshua V. Dillon 2019-03-01 17:24:16 -08:00 committed by TensorFlower Gardener
parent fc33a70c90
commit ebeb598c2d

View File

@ -310,7 +310,8 @@ class Layer(trackable.Trackable):
ValueError: When giving unsupported dtype and no initializer or when
trainable has been set to True with synchronization set as `ON_READ`.
"""
shape = shape or ()
if shape is None:
shape = ()
# Validate optional keyword arguments.
for kwarg in kwargs:
if kwarg not in ['getter', 'collections', 'experimental_autocast']: