aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar A. Unique TensorFlower <gardener@tensorflow.org>2018-10-09 15:18:21 -0700
committerGravatar TensorFlower Gardener <gardener@tensorflow.org>2018-10-09 15:22:35 -0700
commit771955e2b8be98a0b38fada41bd67f663397c87d (patch)
tree81acb788cf839f86058cbc739f4396a4167c5ca7
parent5f69248a692f7b47ea11930621f4f19d0397fe8c (diff)
Raises an appropriate error if `add_weight` is called on a Keras network.
PiperOrigin-RevId: 216432358
-rw-r--r--tensorflow/python/keras/engine/network.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/tensorflow/python/keras/engine/network.py b/tensorflow/python/keras/engine/network.py
index 5969fea2b2..266c48d304 100644
--- a/tensorflow/python/keras/engine/network.py
+++ b/tensorflow/python/keras/engine/network.py
@@ -432,6 +432,27 @@ class Network(base_layer.Layer):
'assign variables to attributes and they will show up in the weights '
'and variables properties.')
+ def add_weight(self,
+ name,
+ shape,
+ dtype=None,
+ initializer=None,
+ regularizer=None,
+ trainable=None,
+ constraint=None,
+ partitioner=None,
+ use_resource=None,
+ synchronization=variables.VariableSynchronization.AUTO,
+ aggregation=variables.VariableAggregation.NONE,
+ **kwargs):
+ if self._is_graph_network:
+ raise NotImplementedError('`add_weight` is not supported on Networks.')
+ else:
+ raise NotImplementedError(
+ '`add_weight` is not supported on Networks. However, you may '
+ 'assign variables to attributes and they will show up in the weights '
+ 'and variables properties.')
+
def add_loss(self, *args, **kwargs):
if context.executing_eagerly():
raise NotImplementedError('`add_loss` is not supported on Networks '