Theano-功能 (Theano - Functions)
Theano function acts like a hook for interacting with the symbolic graph. A symbolic graph is compiled into a highly efficient execution code. It achieves this by restructuring mathematical equations to make them faster. It compiles some parts of the expression into C language code. It moves some tensors to the GPU, and so on.
Theano 函数的作用就像是一个与符号图进行交互的钩子。 将符号图编译为高效的执行代码。 它通过重构数学方程以使其更快来实现这一点。 它将表达式的某些部分编译为C语言代码。 它将一些张量移动到GPU,等等。
The efficient compiled code is now given as an input to the Theano function. When you execute the Theano function, it assigns the result of computation to the variables specified by us. The type of optimization may be specified as FAST_COMPILE or FAST_RUN. This is specified in the environment variable THEANO_FLAGS.
现在,将有效的编译代码作为Theano 函数的输入。 当执行Theano 函数时 ,它将计算结果分配给我们指定的变量。 优化类型可以指定为FAST_COMPILE或FAST_RUN。 这是在环境变量THEANO_FLAGS中指定的。
A Theano function is declared using the following syntax −
Theano 函数使用以下语法声明-
f = theano.function ([x], y)
The first parameter [x] is the list of input variables and the second parameter y is the list of output variables.
第一个参数[x]是输入变量的列表,第二个参数y是输出变量的列表。
Having now understood the basics of Theano, let us begin Theano coding with a trivial example.
现在已经了解了Theano的基础知识,让我们从一个简单的例子开始Theano编码。
翻译自: https://www.tutorialspoint.com/theano/theano_functions.htm