ifelse和theano切换的目的是什么? [英] What is purpose of ifelse and switch in theano?
问题描述
我对它们一无所知,我从 http://阅读deeplearning.net/software/theano/tutorial/conditions.html .我想它们的功能就像我们的ifelse,但无法理解如何使用它们.请对此提供一些指导.谢谢
I am not able to understand anything about them, I read it from http://deeplearning.net/software/theano/tutorial/conditions.html. I suppose they function like our ifelse but not able to understand how to use them. Please some guide on this. Thanks
推荐答案
我认为它只是对三个符号变量起作用的另一个运算符,如果第一个为true,则返回第二个,否则返回第三个.
I would think of it as just another operator that acts on three symbolic variables, if the first is true, return the second, else return the third.
但是对于许多运算符(例如-
和+
),theano已将它们重载为符号变量,因此,您可能不会感到有什么区别.
But for many operators (like -
and +
) theano has overloaded them for symbolic variables, so probably you don't feel the difference.
例如,如果a
和b
是数字,则c=a+b
创建一个值为a+b
的变量c
.如果a
和b
是符号变量,则c=a+b
创建另一个符号变量c
,当相应的函数被调用/求值时,它将对元素a
和b
应用(逐元素)加法.
For example, if a
and b
are numbers, then c=a+b
creates a variable c
with the value of a+b
. If a
and b
are symbolic variables, then c=a+b
creates another symbolic variable c
, that will apply (element-wise) addition to a
and b
when the corresponded function gets called/evaluated.
这里是theano运算符和图形的介绍. http://deeplearning.net/software/theano/extending/graphstructures.html
Here's an introduction on theano operators and graphs. http://deeplearning.net/software/theano/extending/graphstructures.html
三元运算符是python与theano的ifelse
或switch
表示符号变量.
The ternary operator is python's native equivalent to theano's ifelse
or switch
for symbolic variables in some sense.
这篇关于ifelse和theano切换的目的是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!