tensorflow 中的 gen_math_ops 脚本在哪里?
Where is gen_math_ops script in tensorflow?
我在github上阅读了tensorflow的源代码,发现gen_math_ops被导入了。
from tensorflow.python.ops import gen_math_ops
但是,我在整个项目中找不到这个脚本,而且它也不在 ops 文件夹下。
此文件是机器生成的。
您可以在.../site-packages/tensorflow/python/ops/gen_math_ops.py
中找到生成的文件
例如Mac,可以在/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/tensorflow/python/ops/gen_math_ops.py.
根据tf_gen_op_wrapper_*
规则自动生成here。
你也可以用??在您的 IPython 笔记本中查找位置
Yaroslav 有正确答案,但他提供的 link 现在已损坏。这是 correct link to tensorflow.bzl。
就我而言,我对 gen_array_ops._concat 的内部运作很感兴趣。事实证明,gen*.py 是为位于 here. You can typically guess the kernel op name, e.g., here 的 C++ 内核自动生成的包装器,正是我感兴趣的那个。
只是为了补充以前的答案,如果您的目标是检查源代码,请尝试 inspect.get_source
:
我在github上阅读了tensorflow的源代码,发现gen_math_ops被导入了。
from tensorflow.python.ops import gen_math_ops
但是,我在整个项目中找不到这个脚本,而且它也不在 ops 文件夹下。
此文件是机器生成的。
您可以在.../site-packages/tensorflow/python/ops/gen_math_ops.py
中找到生成的文件例如Mac,可以在/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/tensorflow/python/ops/gen_math_ops.py.
根据tf_gen_op_wrapper_*
规则自动生成here。
你也可以用??在您的 IPython 笔记本中查找位置
Yaroslav 有正确答案,但他提供的 link 现在已损坏。这是 correct link to tensorflow.bzl。
就我而言,我对 gen_array_ops._concat 的内部运作很感兴趣。事实证明,gen*.py 是为位于 here. You can typically guess the kernel op name, e.g., here 的 C++ 内核自动生成的包装器,正是我感兴趣的那个。
只是为了补充以前的答案,如果您的目标是检查源代码,请尝试 inspect.get_source
: