简体   繁体   English

用C ++和Python编写的所有Tensorflow算法都只是易于使用的API吗?

[英]Are all the algorithms of Tensorflow written in C++ and Python only serve to be easy-to-use APIs?

I know that Tensorflow is written with a C++ engine, but I haven't found any C++ source code in my installation directory (I installed via pip). 我知道Tensorflow是用C ++引擎编写的,但我在安装目录中找不到任何C ++源代码(我是通过pip安装的)。 When I inspect the python codes, I got a sense that the python level is just a wrapper where the essence of the algorithm is not presented. 当我检查python代码时,我感觉到python级别只是一个包装器,其中没有呈现算法的本质。 For example, in tensorflow/python/ops/gradients.py , the gradients() function calls python_grad_func() to compute the gradients, which is a class method of DeFun . 例如,在tensorflow/python/ops/gradients.pygradients()函数调用python_grad_func()来计算渐变,这是DeFun的类方法。

My question is that, are all the essential part of Tensorflow written in C++ and the python are only serving as some APIs? 我的问题是,用C ++编写的Tensorflow的所有必要部分是什么,python只作为一些API?

This is mostly correct, though there's a lot of sophisticated stuff implemented in Python. 这大多是正确的,尽管在Python中实现了很多复杂的东西。 Instead of saying "algorithms" in C++, what I'd say is that the core dataflow execution engine and most of the ops (eg, matmul, etc.) are in C++. 我不是在C ++中说“算法”,而是说核心数据流执行引擎和大多数操作(例如matmul等)都是用C ++编写的。 A lot of the plumbing, as well as some functionality like defining gradients of functions, is in Python. 很多管道,以及定义函数渐变等功能都在Python中。

For more information and discussion about why it's this way, see this StackOverflow answer 有关这种方式的更多信息和讨论,请参阅此StackOverflow答案

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

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