ifelse和theano切换的目的是什么? [英] What is purpose of ifelse and switch in theano?

查看:83
本文介绍了ifelse和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.

例如,如果ab是数字,则c=a+b创建一个值为a+b的变量c.如果ab是符号变量,则c=a+b创建另一个符号变量c,当相应的函数被调用/求值时,它将对元素ab应用(逐元素)加法.

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的ifelseswitch表示符号变量.

The ternary operator is python's native equivalent to theano's ifelse or switch for symbolic variables in some sense.

这篇关于ifelse和theano切换的目的是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆