Skip to content
This repository was archived by the owner on Jul 7, 2023. It is now read-only.

Commit ee66a0a

Browse files
dustinvtranCopybara-Service
authored andcommitted
Fix open-source dependence on dimension_value.
PiperOrigin-RevId: 219223793
1 parent c47bb7e commit ee66a0a

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

tensor2tensor/layers/bayes.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@
2121

2222
import tensorflow as tf
2323

24-
from tensorflow.python.framework import tensor_shape
25-
2624

2725
class Softplus(tf.keras.constraints.Constraint):
2826
"""Softplus constraint."""
@@ -183,10 +181,12 @@ def __init__(self,
183181

184182
def build(self, input_shape):
185183
input_shape = tf.TensorShape(input_shape)
186-
if tensor_shape.dimension_value(input_shape[-1]) is None:
184+
last_dim = input_shape[-1]
185+
if isinstance(last_dim, tf.Dimension):
186+
last_dim = last_dim.value
187+
if last_dim is None:
187188
raise ValueError('The last dimension of the inputs to `Dense` '
188189
'should be defined. Found `None`.')
189-
last_dim = tensor_shape.dimension_value(input_shape[-1])
190190
self.input_spec = tf.layers.InputSpec(min_ndim=2,
191191
axes={-1: last_dim})
192192
self.kernel = self.kernel_initializer([last_dim, self.units],

0 commit comments

Comments
 (0)