【发布时间】:2017-03-01 00:26:58
【问题描述】:
在 TensorFlow source,我明白了,
REGISTER_OP("BroadcastGradientArgs")
.Input("s0: T")
.Input("s1: T")
.Output("r0: T")
.Output("r1: T")
.Attr("T: {int32, int64} = DT_INT32")
.SetShapeFn([](InferenceContext* c) {
... uninteresting details ...
})
.Doc(R"doc(
Return the reduction indices for computing gradients of s0 op s1 with broadcast.
This is typically used by gradient computations for a broadcasting operation.
)doc");
在 Python 中,我可以执行以下操作,
>>> from tensorflow.python.ops import gen_array_ops
>>> gen_array_ops._InitOpDefLibrary()._ops['BroadcastGradientArgs'].op_def
name: "BroadcastGradientArgs"
input_arg {
name: "s0"
type_attr: "T"
}
... more stuff ...
attr {
name: "T"
type: "type"
... uninteresting details ...
}
请注意,我在 Python 中获取了 TF 操作的 Protobuf 定义(为简洁起见,我删除了一些)。我想获得我在 C++ 代码中看到的定义的文档部分。如何获得?
【问题讨论】:
-
该信息 (.Doc) 存在于 TF 源代码中,但它没有通过 python 包装器导出,因此在 Python 中不可用。看here,这是您在python 中使用的
op_def生成的地方。需要在此处实现一些代码,以便您可以在 python 中访问这些文档。 -
谢谢。 github.com/tensorflow/tensorflow/blob/… 似乎是从 OpDef 中删除描述的位置。这是真的?如果我删除github.com/tensorflow/tensorflow/blob/… 行,OpDef 的文档是否仍然存在于 Protobuf 中?
-
取消注释该行会导致 protobuf 出现一系列问题。也许有更好的方法。 github.com/google/protobuf/issues/2798
-
我不认为修复那么容易..
-
@arash 这一点都不容易。看我的回答。我希望你们谷歌的人能解决这些问题!好痛
标签: c++ tensorflow protocol-buffers