Skip to content

Commit

Permalink
change API calls to make them compatible with older TF versions #254 (#…
Browse files Browse the repository at this point in the history
…260)

* change API calls to make them compatible with older TF versions

* replace 2 more occurences of get_static_value
  • Loading branch information
swapnull7 authored and gpengzhi committed Dec 18, 2019
1 parent 4add294 commit 413e07f
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions texar/tf/modules/decoders/dynamic_decode.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

import tensorflow as tf
from tensorflow.contrib.seq2seq import Decoder as TFDecoder
from tensorflow.python.framework import tensor_shape
from tensorflow.python.framework import tensor_shape, tensor_util
from tensorflow.python.util import nest


Expand Down Expand Up @@ -55,7 +55,7 @@ def _concat(prefix, suffix, static=False):
"""
if isinstance(prefix, tf.Tensor):
p = prefix
p_static = tf.get_static_value(prefix)
p_static = tensor_util.constant_value(prefix)
if p.shape.ndims == 0:
p = tf.expand_dims(p, 0)
elif p.shape.ndims != 1:
Expand All @@ -69,7 +69,7 @@ def _concat(prefix, suffix, static=False):
if p.is_fully_defined() else None)
if isinstance(suffix, tf.Tensor):
s = suffix
s_static = tf.get_static_value(suffix)
s_static = tensor_util.constant_value(suffix)
if s.shape.ndims == 0:
s = tf.expand_dims(s, 0)
elif s.shape.ndims != 1:
Expand Down Expand Up @@ -128,7 +128,7 @@ def _transpose_batch_time(x):
x transposed along the first two dimensions.
"""
x_static_shape = x.get_shape()
if x_static_shape.rank is not None and x_static_shape.rank < 2:
if x_static_shape.ndims is not None and x_static_shape.ndims < 2:
return x

x_rank = tf.rank(x)
Expand Down Expand Up @@ -209,7 +209,7 @@ def _shape(batch_size, from_shape):
from_shape.ndims == 0):
return None
else:
batch_size = tf.get_static_value(
batch_size = tensor_util.constant_value(
tf.convert_to_tensor(
batch_size, name="batch_size"))
return tensor_shape.TensorShape([batch_size]).\
Expand Down

0 comments on commit 413e07f

Please sign in to comment.