首页 > 其他 > 详细

[theano]入门-变量相加、矩阵声明

时间:2015-01-17 20:46:22      阅读:259      评论:0      收藏:0      [点我收藏+]
#作为python新手,可能学习的东西比较多,注意如果两个矩阵相乘的话,跟matlab区别还是挺大的
#
!/usr/bin/env python # coding=utf-8 #格式一般用import ss as d import theano.tensor as T from theano import function import numpy as np #声明变量 x=T.dscalar(x) y=T.dscalar(y) z=x+y f=function([x,y],z) #call the function f(2,3) print f(2,3) #declare the varalble x=T.dmatrix(x) y=T.dmatrix(y) z=x+y f=function([x,y],z) c=f([[1,2],[3,5]],[[1,3],[3,5]]) print c[0,0] #shape function will return the size of a array d=np.shape(c) print d a=3 b=2 #** means mici c=a**2 print c a=T.vector() out=a**10 f=function([a],out) print f([1,2,3])

 

[theano]入门-变量相加、矩阵声明

原文:http://www.cnblogs.com/taokongcn/p/4230979.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!