Theano tutorial – basic type
博客摘自:Deep learning 第二篇 婴儿学步 Theano如何做算数?
import theano.tensor as T
from theano import function x=T.dscalar('x')
y=T.dscalar('y')
z=x+y
f=function([x,y],z)
print f(2,3)
输出:
5.0
两个矩阵相加:
x=T.dmatrix('x') #注意这里使用矩阵类型进行格式化
y=T.dmatrix('y')
z=x+y
f2=function([x,y],z)
print f2([1,2],[3,4],[10,20],[30,40])
到这里,手册里面出现了3个专业名词:
scalars ----标量:只有大小,没有方向。比如欧几里几何中的两点的距离。
matrix ----矩阵:一种数学标记方法,通常由行和列组成.
vectors ---向量:也常称为矢量,即有方向的量,与标量相对。
可以用来做加法的变量:
The following types are available:
byte: bscalar, bvector, bmatrix, brow, bcol, btensor3, btensor4
16-bit integers: wscalar, wvector, wmatrix, wrow, wcol, wtensor3, wtensor4
32-bit integers: iscalar, ivector, imatrix, irow, icol, itensor3, itensor4
64-bit integers: lscalar, lvector, lmatrix, lrow, lcol, ltensor3, ltensor4
float: fscalar, fvector, fmatrix, frow, fcol, ftensor3, ftensor4
double: dscalar, dvector, dmatrix, drow, dcol, dtensor3, dtensor4
complex: cscalar, cvector, cmatrix, crow, ccol, ctensor3, ctensor4
import numpy import theano.tensor as T
from theano import function
#from numpy import asarray
#from PIL import Image
#im=Image.open("/Users/chaimwu/Desktop/test.png")
#im.rotate(45).show()
print "OK!"
#print random.rand(4,4) print numpy.asarray([1,2],[3,4],[5,6]).shape
print numpy.asarray([1,2],[3,4],[5,6])[2,0] a = numpy.asarray([1.0, 2.0, 3.0])
b=2.0
print a*b
print b*a x=T.dscalar('x')
y=T.dscalar('y')
z=x+y
f1=function([x,y],z) print f1(1,3) x=T.dmatrix('x')
y=T.dmatrix('y')
z=x+y
f2=function([x,y],z) print f2([1,2],[3,4],[10,20],[30,40]) x=T.dmatrix()
y=T.dmatrix()
z=x+2**y
f3=function([x,y],z) print f3([1,2],[3,4],[10,20],[30,40]) x=T.dvector()
y=T.dvector()
z=2*x+2**y
f4=function([x,y],z) print f4([2,3],[4,5])
Theano tutorial – basic type的更多相关文章
- React Tutorial: Basic Concept Of React Component---babel, a translator
Getting started with react.js: basic concept of React component 1 What is React.js React, or React.j ...
- ZetCode PyQt4 tutorial basic painting
#!/usr/bin/python # -*- coding: utf-8 -*- """ ZetCode PyQt4 tutorial In this example, ...
- [Web Service] Tutorial Basic Concepts
WSDL是网络服务描述语言,是一个包含关于web service信息(如方法名,方法参数)以及如何访问它. WSDL是UDDI的一部分. 作为web service 应用程序之间的接口,发音为wiz- ...
- Struts 2 Tutorial Basic MVC Architecture
Model View Controller or MVC as it is popularly called, is a software design pattern for developing ...
- paper 167:GPU的使用Theano之tutorial
Theano之使用GPU 英文版本:http://deeplearning.net/software/theano/tutorial/using_gpu.html using the ...
- 【theano】tutorial
http://deeplearning.net/software/theano/tutorial/index.html#tutorial
- Theano2.1.17-基础知识之剖析theano的函数
来自:http://deeplearning.net/software/theano/tutorial/profiling.html Profiling Theano function note:该方 ...
- Theano2.1.18-基础知识之theano的扩展
来自:http://deeplearning.net/software/theano/tutorial/extending_theano.html Extending Theano 该教程覆盖了如何使 ...
- [转载] CMake Official Tutorial——教程还是官方的好
CMake官方教程传送门:https://cmake.org/cmake-tutorial/ 以下的内容跟官方教程基本一致,少数地方根据自己的测试有所改动: A Basic Starting Poin ...
随机推荐
- 基于Laravel+Swoole开发智能家居后端
基于Laravel+Swoole开发智能家居后端 在上一篇<Laravel如何优雅的使用Swoole>中我已经大概谈到了Laravel结合Swoole的用法. 今天,我参与的智能家居项目基 ...
- 硬件升级win8.1重新安装系统
上次重装系统一年后升级了硬件配置,双11后,再次折腾系统. 配置硬件的选择 部分配件已经升级过了,之前的一直是AMD平台,发热大功耗高,08年我配的AMD 8450+映泰GX790 128M待机在10 ...
- .Net相关
Lucene 全文搜索 http://lucenenet.apache.org/ Memcached 分布式缓存 http://memcached.org/ selenium UI自动化测试 http ...
- iOS不得姐项目--pop框架的初次使用
一.pop和Core Animation的区别 1.Core Animation的动画只能添加到layer上 2.pop的动画能添加到任何对象 3.pop的底层并非基于Core Animation,是 ...
- JavaScript使用自定义事件实现简单的模块化开发
WEB前端最常见驱动方式就是事件了, 所有交互等等都是通过事件,前端的常见事件有: UI事件: 焦点事件: 鼠标事件: 滚轮事件: 文本事件: 键盘事件: 变动事件: 现在网页上有一个输入框, 如果我 ...
- 网络流 最大流HDU 3549
//////////在这幅图中我们首先要增广1->2->4->6,这时可以获得一个容量为2的流,但是如果不建立4->2反向弧的话,则无法进一步增广,最终答案为2,显然是不对的, ...
- git将本地代码 和服务器git@osc 上的代码 关联
将本地代码 和服务器git@osc 上的代码 关联 要使用git 首先,你得安装一个git 下载 http://git-scm.com/downloads 安装完成后,需要简单的配置一下,打开 Git ...
- 给自定义cell设置分隔线的不同做法
1.给cell添加一个UIView,设置UIView的高度为1,并设置这个UIView的左.下.右约束. 2.不需要给cell添加任何控件,重写cell的- (void)setFrame:(CGRec ...
- 64.GitHub 排名前100的android项目简介
GitHub Android Libraries Top 100 简介 排名完全是根据 GitHub 搜索 Java 语言选择 (Best Match) 得到的结果, 然后过滤了跟 Android 不 ...
- BZOJ 1121: [POI2008]激光发射器SZK
1121: [POI2008]激光发射器SZK Time Limit: 10 Sec Memory Limit: 162 MBSubmit: 792 Solved: 653[Submit][Sta ...