![](/img/trans.png)
[英]RuntimeError: No C++ shape function registered for standard op: NearestNeighbors
[英]Tensorflow: No shape function registered for standard op: ExtractGlimpse. Where do I add my code for the shape function?
我正在嘗試使用tf.image.extract_glimpse
構建張量流圖。
不幸的是,我認為API本身存在錯誤。 我收到錯誤, 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]])]
由於某種原因,該函數未正確使用,但是從文檔中確切調用該函數的位置尚不清楚。
應該在哪個python文件中調用此函數,以及如何使用該調用?
提前致謝
這看起來像TensorFlow中的錯誤:形狀函數在正確的位置定義,但是attention_ops.py
_ops.py中的代碼從未執行,因此形狀函數從未注冊。
我將在上游對其進行修復,但與此同時,您可以通過在程序中添加以下行來對其進行修復:
from tensorflow.python.ops import attention_ops
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.