tensorflow - {TypeError}Using a `tf.Tensor` as a Python `bool` is not allowed -
i create tfrecord of sequences, , trying parse using:
context, sequence = tf.parse_single_sequence_example( serialized_example, context_keys_to_features, # {'label': fixedlenfeature(shape=[], dtype=tf.int64, default_value=none)} sequence_keys_to_features # {'token': fixedlensequencefeature(shape=[], dtype=tf.int64, allow_missing=false, default_value=none)} )
if try evaluate value of context
, sequence
, following:
tf.contrib.learn.run_n(sequence) >> {'token': array([ 17, 10, 6, 878, 25, ... ])}
same context:
tf.contrib.learn.run_n(context) >> {'label': 1}
but when try, evaluate tensor inside the dict, raises error:
# next line raise error tf.contrib.learn.run_n(sequence['token']) # line tf.contrib.learn.run_n(context['label']) >> {typeerror}using `tf.tensor` python `bool` not allowed. use `if t not none:` instead of `if t:` test if tensor defined, , use tensorflow ops such tf.cond execute subgraphs conditioned on value of tensor.
any ideas why case, checked whole pipeline, , don't seem use if
instead of tf.cond
or other operations raise condition.
Comments
Post a Comment