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 ...
随机推荐
- Nodejs基础:路径处理模块path总结
模块概览 在nodejs中,path是个使用频率很高,但却让人又爱又恨的模块.部分因为文档说的不够清晰,部分因为接口的平台差异性. 将path的接口按照用途归类,仔细琢磨琢磨,也就没那么费解了. 获取 ...
- 东大OJ-Max Area
1034: Max Area 时间限制: 1 Sec 内存限制: 128 MB 提交: 40 解决: 6 [提交][状态][讨论版] 题目描述 又是这道题,请不要惊讶,也许你已经见过了,那就请你再 ...
- ios8调用相机报警告: Snapshotting a view that has not been rendered results in an empty snapshot. Ensure you(转)
我这也报了这个警告,但按他的方法并没有起作用,把写到这个地方看是否其他人用的到 错误代码:Snapshotting a view that has not been rendered results ...
- Jenkins的maven工程打包的时候怎么指定不同环境的配置文件
http://outofmemory.cn/code-snippet/6643/maven-profile-define-enviroment-package 在打包的时候我们添加上 这里我们指定配置 ...
- 长串英文数字强制折行解决办法css
overflow: hidden; white-space: normal; word-warp: break-word; word-break: break-all;/*Only work in I ...
- [转] DBCP 的validationQuery
原文地址:http://blog.csdn.net/fgakjfd/article/details/5600462 网上很多评论说DBCP有很多BUG,但是都没有指明是什么BUG,只有一部分人说数据库 ...
- Android获取屏幕宽度、高度的4种方法
记录学习之用,有相同的问题可以参考 方法一: WindowManager wm = (WindowManager) this .getSystemService(Context.WINDOW_SERV ...
- 【BZOJ 1568】【JSOI 2008】Blue Mary开公司
经典的splay维护凸壳,但是看了看zky学长的题解最后决定写线段树维护标记永久化. Round1考到了这个之后一直没有理解标记永久化,CTSC也因为自己的缺陷丢掉了一些部分分,so sad 看来以后 ...
- 【BZOJ 1043】【HNOI 2008】下落的圆盘 判断圆相交+线段覆盖
计算几何真的好暴力啊. #include<cmath> #include<cstdio> #include<cstring> #include<algorit ...
- 关于二叉排序树 BST
#include<stdio.h> #include<stdlib.h> typedef struct node { double w; struct node *l,*r; ...