How to Using Theano
来源:互联网 发布:中国服务贸易数据 编辑:程序博客网 时间:2024/05/22 08:16
使用theano的function生成公式的时候,需要首先声明symbol(variable)变量,这个变量可以是很多类型,比如scalar、vector或者matrix等类型。
如果要实现如下的向量计算公式:
out = a^2 + b^2 + 2*a*b
则可以使用下面的代码完成:
In [1]: import theano.tensor as TIn [2]: from theano import functionIn [3]: a = T.dvector('a')In [4]: b = T.dvector('b')In [5]: out = a**2 + b**2 + 2*a*bIn [6]: f = function([a, b], out)In [7]: f([1, 2], [3, 4])Out[7]: array([ 16., 36.])
通过这个可以方便的实现一个sigmoid函数,sigmoid(x) = 1/(1+exp(-x))。
In [8]: x = T.dmatrix('x')In [9]: s = 1 / (1 + T.exp(-x))In [10]: logistic = function([x], s)In [11]: logistic([[0,1], [1, 2], [-1, -2]])Out[11]: array([[ 0.5 , 0.73105858], [ 0.73105858, 0.88079708], [ 0.26894142, 0.11920292]])
0 0
- How to Using Theano
- How to Using exploits.
- How to using TOR
- HOW TO: Using CVS
- How to Connect to MySQL Using C#
- how to using CommandArgument in DataGrid
- how to display '&' in subject using mailto?
- How To Enumerate Applications Using Win32 APIs
- [转]How To Setup MogileFS & Using MogileFS
- How to Using the FortiUSB key
- How To Setup MogileFS & Using MogileFS
- [转]How To Setup MogileFS & Using MogileFS
- [转]How To Setup MogileFS & Using MogileFS
- How to Submit a Form Using JavaScript
- How to compile SonicUI using VC6.0?
- How to Get Hardware Information using C#
- How to submmit jobs using Condor_G
- How to size text using ems
- 利用Hierarchy Viewer优化布局
- id ,NSObject, id<NSObject>区别
- TreeMap小练习
- mediawiki 只能本机访问 其他电脑不能访问
- 史上最全的手机聊天室开发经验分享上
- How to Using Theano
- 把项目下的jar迁移到tomcat的lib目录下,原本的logback日志配置会失效,产生大量debugger级别日志
- Android 蓝牙开发 UUID列表
- 一个成功的程序员的故事
- 【资料】SVN源码服务器搭建-详细教程
- c#调用c++动态库的一些理解
- GPG签名验证错误 NO_PUBKEY问题
- android webview addJavascriptInterface 的方法不能调用
- 函数指针、函数指针数组和指针函数