我试图用tf.image.extract_glimpse
建立一个张量流图。在
不幸的是,我认为API本身有一个bug。我收到错误No shape function registered for standard op: ExtractGlimpse
实际上,/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/attentions_ops.py
中有以下代码:
@ops.RegisterShape("ExtractGlimpse")
def _ExtractGlimpseShape(op):
"""Shape function for ExtractGlimpse op."""
input_shape = op.inputs[0].get_shape().with_rank(4)
unused_size_shape = op.inputs[1].get_shape().merge_with(
tensor_shape.vector(2))
offsets_shape = op.inputs[2].get_shape().merge_with(
input_shape[:1].concatenate([2]))
offsets_shape = offsets_shape
size_value = tensor_util.ConstantValue(op.inputs[1])
if size_value is not None:
height = size_value[0]
width = size_value[1]
else:
height = None
width = None
return [tensor_shape.TensorShape(
[input_shape[0], height, width, input_shape[3]])]
由于某些原因,这个函数没有被正确地使用,但是从documentation调用这个函数的确切位置还不完全清楚。在
这个函数应该在哪个python文件中调用,该调用需要如何使用?在
提前谢谢
这看起来像是TensorFlow中的一个bug:shape函数定义在正确的位置,但是
attention_ops.py
中的代码从未执行,因此shape函数从未注册。在我将在上游修复它,但同时您可以通过在程序中添加以下行来修复它:
相关问题 更多 >
编程相关推荐