Tensorflow: No shape function registered for standard op: ExtractGlimpse. Where do I add my code for the shape function?
Question: I am trying to build a tensorflow graph using `tf.image.extract_glimpse`.

Unfortunately I think there is a bug in the API itself. I am receiving the
error `No shape function registered for standard op: ExtractGlimpse`

There is actually the following code in `/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]])]
    

For some reason this function isn't being used properly, however it's not
entirely clear from the
[documentation](https://www.tensorflow.org/versions/master/how_tos/adding_an_op/index.html#implement-
a-shape-function-in-python) where exactly this function is called.

In which python file is this function supposed to be called, and how does the
call need to be used?

Thanks in advance


Answer: This looks like a bug in TensorFlow: the shape function is defined in the
correct place, but the code in `attention_ops.py` is never executed, so the
shape function is never registered.

I will fix it upstream, but in the meantime you can fix it by adding the
following line to your program:

    
    
    from tensorflow.python.ops import attention_ops
    

