Tensorflow v1.0 included a lot of changes to keeping up to date is important. A lot of things were fixable with the tensorflow upgrade script but changes to tf.split() caused errors.
Traceback (most recent call last):
File "encoder.py", line 209, in <module>
mdl = Model()
File "encoder.py", line 143, in __init__
cells, states, logits = model(X, S, M, reuse=False)
File "encoder.py", line 93, in model
inputs = [tf.squeeze(v, [1]) for v in tf.split(axis=1, num_or_size_splits=nsteps, value=words)]
File "/Users/rupertdeese/.pyenv/versions/3.5.0/lib/python3.5/site-packages/tensorflow/python/ops/array_ops.py", line 1203, in split
num = size_splits_shape.dims[0]
IndexError: list index out of range
This error was because nsteps is passed into tf.split as the num_os_size_splits argument but nsteps is a "Dimension" this was fine when tf.split() looked like this
in v1.0 tf.split() changed not only the order of arguments but the function is now
def split(value, num_or_size_splits, axis=0, num=None, name="split"):
if isinstance(num_or_size_splits, six.integer_types):
return gen_array_ops._split(
split_dim=axis, num_split=num_or_size_splits, value=value, name=name)
else:
size_splits = ops.convert_to_tensor(num_or_size_splits)
if num is None:
size_splits_shape = size_splits.get_shape()
num = size_splits_shape.dims[0]
if num._value is None:
raise ValueError("Cannot infer num from shape %s" % num_or_size_splits)
return gen_array_ops._split_v(
value=value,
size_splits=size_splits,
split_dim=axis,
num_split=num,
name=name)
Now when tf.split() is called, if isinstance(num_or_size_splits, six.integer_types): returns false and the code tries to get the Dimension's shape but it is an empty list so .dims[0] fails.
This pull request fixes the simple argument switching, function renaming incompatibilities in encoder.py and also fixes the above bug concerning tf.split()
Tensorflow v1.0 included a lot of changes to keeping up to date is important. A lot of things were fixable with the tensorflow upgrade script but changes to tf.split() caused errors.
This error was because nsteps is passed into tf.split as the num_os_size_splits argument but nsteps is a "Dimension" this was fine when tf.split() looked like this
in v1.0 tf.split() changed not only the order of arguments but the function is now
Now when tf.split() is called, if isinstance(num_or_size_splits, six.integer_types): returns false and the code tries to get the Dimension's shape but it is an empty list so .dims[0] fails.
This pull request fixes the simple argument switching, function renaming incompatibilities in encoder.py and also fixes the above bug concerning tf.split()