简体   繁体   English

如何在 tensorflow 的源代码中打印(跟踪)

[英]How to print (trace) within tensorflow's source code

I have a small trial to print out something within tensorflow's kernel.我有一个小的尝试来打印 tensorflow 内核中的一些东西。

ex, I would like to print something within例如,我想在里面打印一些东西

https://www.tensorflow.org/api_docs/python/tf/train/GradientDescentOptimizer https://www.tensorflow.org/api_docs/python/tf/train/GradientDescentOptimizer

Then I search for the corresponding sources in my laptop where Ubuntu 16.04 has been installed.然后我在安装了 Ubuntu 16.04 的笔记本电脑中搜索相应的源。

Below are what I found.下面是我发现的。

在此处输入图片说明

I think gradient_descent.py within either我认为gradient_descent.py 要么

/usr/local/lib/python3.5/dist-packages/tensorflow/contrib/optimizer_v2 /usr/local/lib/python3.5/dist-packages/tensorflow/contrib/optimizer_v2

or或者

/usr/local/lib/python3.5/dist-packages/tensorflow/python/training /usr/local/lib/python3.5/dist-packages/tensorflow/python/training

are used.被使用。 Hence I modify them both.因此我修改了它们。

However, I cannot see the modifications.但是,我看不到修改。

I wonder why it failed.我想知道为什么它失败了。

Is there any way the trace Tensorflow source code (I know C & C++ part needs to be re-compile so focus on Python now)?有没有办法跟踪 Tensorflow 源代码(我知道 C & C++ 部分需要重新编译,所以现在专注于 Python)?

Thanks in advance.提前致谢。

Check CurrentStackTrace API provided by TensorFlow util .检查TensorFlow util提供的CurrentStackTrace API。 An example use can be found here .可以在此处找到示例用法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM