我已经从源代码构建了tensorflow。我在加载数据时使用tf.cond来选择要加载的图像。它看起来像这样:
reader = tf.TFRecordReader()
_, serialized_example = reader.read(filename_queue)
features = tf.parse_single_example(
serialized_example,
features={
'label': tf.FixedLenFeature([], tf.float32),
'right': tf.VarLenFeature(tf.string),
'center': tf.VarLenFeature(tf.string),
'left': tf.VarLenFeature(tf.string)
})
label = features['label']
image, label = tf.cond(rand < -0.7, lambda: (features['right'],label + 0.08), lambda: (features['center'], label))
image, label = tf.cond(rand > 0.7, lambda: (features['left'], label - 0.08), lambda: (image,label))
对于源代码版本(大约0.11rc1),这可以很好地完成,但是在其他机器上安装了带有0.11rc2(和rc1)的pip我得到以下错误:
File "./example_reader.py", line 29, in read_and_decode_single_example
image, label = tf.cond(rand < -0.7, lambda: (features['right'],label + 0.08), lambda: (features['center'], label))
File "./local/lib/python2.7/site-packages/tensorflow/python/ops/control_flow_ops.py", line 1710, in cond
orig_res, res_t = context_t.BuildCondBranch(fn1)
File "./local/lib/python2.7/site-packages/tensorflow/python/ops/control_flow_ops.py", line 1626, in BuildCondBranch
elif v.name not in self._values:
AttributeError: 'SparseTensor' object has no attribute 'name'
我不知道这里有什么问题......希望你能帮助我。
答案 0 :(得分:0)
SparseTensor的API可能在两个版本之间发生了变化。试试1.0版本,看看问题是否仍然存在。