国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

theano學習初步(二) 基礎Tensor函數

2019-11-14 12:27:30
字體:
來源:轉載
供稿:網友

http://blog.csdn.net/u013007900/article/details/52447561

theano學習初步(二) 基礎Tensor函數

2016-09-06 11:26 1929人閱讀 評論(0) 收藏 舉報 分類:

目錄(?)[+]

本文來自于官方文檔

Creation(聲明)

Theano有多種方式進行聲明變量。變量也可以進行命名,從而便于debug,而且每一種聲明方式都能夠接受name的參數。 下面這三種聲明方式,聲明的是0維的整型變量,它的名字是myvar

>>> x = scalar('myvar', dtype='int32')>>> x = iscalar('myvar')>>> x = TensorType(dtype='int32', broadcastable=())('myvar')123123

Constructors with optional dtype(用dtype參數進行聲明)

theano.tensor.scalar(name=None, dtype=config.floatX)11

返回一個0維的numpy.ndarray。

theano.tensor.vector(name=None, dtype=config.floatX)11

返回一個1維的numpy.ndarray。

theano.tensor.row(name=None, dtype=config.floatX)11

返回一個2維的numpy.ndarray,但是行數保證是1。

theano.tensor.col(name=None, dtype=config.floatX)11

返回一個2維的numpy.ndarray,但是列數保證是1。

theano.tensor.matrix(name=None, dtype=config.floatX)11

返回一個2維的numpy.ndarray。

theano.tensor.tensor3(name=None, dtype=config.floatX)11

返回一個3維的numpy.ndarray。

theano.tensor.tensor4(name=None, dtype=config.floatX)11

返回一個4維的numpy.ndarray。

All Fully-Typed Constructors(用完整的類型進行聲明)

上文說的dtype在Theano中都有定義。

Constructordtypendimshapebroadcastable
bscalarint80()()
bvectorint81(?,)(False,)
browint82(1,?)(True, False)
bcolint82(?,1)(False, True)
bmatrixint82(?,?)(False, False)
btensor3int83(?,?,?)(False, False, False)
btensor4int84(?,?,?,?)(False, False, False, False)
btensor5int85(?,?,?,?,?)(False, False, False, False, False)
wscalarint160()()
wvectorint161(?,)(False,)
wrowint162(1,?)(True, False)
wcolint162(?,1)(False, True)
wmatrixint162(?,?)(False, False)
wtensor3int163(?,?,?)(False, False, False)
wtensor4int164(?,?,?,?)(False, False, False, False)
wtensor5int165(?,?,?,?,?)(False, False, False, False, False)
iscalarint320()()
ivectorint321(?,)(False,)
irowint322(1,?)(True, False)
icolint322(?,1)(False, True)
imatrixint322(?,?)(False, False)
itensor3int323(?,?,?)(False, False, False)
itensor4int324(?,?,?,?)(False, False, False, False)
itensor5int325(?,?,?,?,?)(False, False, False, False, False)
lscalarint640()()
lvectorint641(?,)(False,)
lrowint642(1,?)(True, False)
lcolint642(?,1)(False, True)
lmatrixint642(?,?)(False, False)
ltensor3int643(?,?,?)(False, False, False)
ltensor4int644(?,?,?,?)(False, False, False, False)
ltensor5int645(?,?,?,?,?)(False, False, False, False, False)
dscalarfloat640()()
dvectorfloat641(?,)(False,)
drowfloat642(1,?)(True, False)
dcolfloat642(?,1)(False, True)
dmatrixfloat642(?,?)(False, False)
dtensor3float643(?,?,?)(False, False, False)
dtensor4float644(?,?,?,?)(False, False, False, False)
dtensor5float645(?,?,?,?,?)(False, False, False, False, False)
fscalarfloat320()()
fvectorfloat321(?,)(False,)
frowfloat322(1,?)(True, False)
fcolfloat322(?,1)(False, True)
fmatrixfloat322(?,?)(False, False)
ftensor3float323(?,?,?)(False, False, False)
ftensor4float324(?,?,?,?)(False, False, False, False)
ftensor5float325(?,?,?,?,?)(False, False, False, False, False)
cscalarcomplex640()()
cvectorcomplex641(?,)(False,)
crowcomplex642(1,?)(True, False)
ccolcomplex642(?,1)(False, True)
cmatrixcomplex642(?,?)(False, False)
ctensor3complex643(?,?,?)(False, False, False)
ctensor4complex644(?,?,?,?)(False, False, False, False)
ctensor5complex645(?,?,?,?,?)(False, False, False, False, False)
zscalarcomplex1280()()
zvectorcomplex1281(?,)(False,)
zrowcomplex1282(1,?)(True, False)
zcolcomplex1282(?,1)(False, True)
zmatrixcomplex1282(?,?)(False, False)
ztensor3complex1283(?,?,?)(False, False, False)
ztensor4complex1284(?,?,?,?)(False, False, False, False)
ztensor5complex1285(?,?,?,?,?)(False, False, False, False, False)

Plural Constructors(多重聲明)

iscalars, lscalars, fscalars, dscalarsivectors, lvectors, fvectors, dvectorsirows, lrows, frows, drowsicols, lcols, fcols, dcolsimatrices, lmatrices, fmatrices, dmatrices

用法參考如下

from theano.tensor import *x, y, z = dmatrices(3) # creates three matrix Variables with no namesx, y, z = dmatrices('x', 'y', 'z') # creates three matrix Variables named 'x', 'y' and 'z'12341234

Custom tensor types(一般的類型聲明)

如果你想要創建一個非標準的類型,那么就只能創造一個你自己定義的TensorType。你需要將dtypebroadcasting pattern傳入聲明函數中。 下面的例子是,自創一個五維向量。

dtensor5 = TensorType('float64', (False,)*5)x = dtensor5()z = dtensor5('z')123123

你也可以重構一個已存在的類型

my_dmatrix = TensorType('float64', (False,)*2)x = my_dmatrix() # allocate a matrix variablePRint my_dmatrix == dmatrix # output is 'True'123123

他們會很好地結合起來。

Converting from Python Objects(從Python對象中轉移)

使用的是shared()函數。

x = shared(numpy.random.randn(3,4))11

這個函數似乎有一些細節,雖然可以這么轉化,但是缺少上面聲明的一些功能。

Shaping and Shuffling

theano.tensor.shape(x)11

返回一個lvector用于表示x的shape

theano.tensor.reshape(x, newshape, ndim=None)11

Parameters:

x (某種TensorVariable (或者是可兼容的類型)) – 要進行reshape的變量newshape (lvector (或者是可兼容的類型)) – x的新形狀ndim – 可選的- the length that newshape‘s value will have. If this is None, then reshape() will infer it from newshape.

Return type:

variable with x’s dtype, but ndim dimensions
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 赣榆县| 丰镇市| 焦作市| 崇左市| 杭锦旗| 固安县| 互助| 晋中市| 连州市| 甘孜| 松桃| 和平区| 南开区| 靖西县| 科技| 仪征市| 铜陵市| 延吉市| 巨鹿县| 蕉岭县| 林州市| 英吉沙县| 韶山市| 苏尼特右旗| 井冈山市| 临沭县| 高雄市| 咸丰县| 灵台县| 万年县| 沾化县| 无为县| 宿松县| 布尔津县| 称多县| 湖北省| 灵武市| 娄底市| 乳源| 安图县| 新绛县|