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

首頁 > 學(xué)院 > 開發(fā)設(shè)計(jì) > 正文

theano學(xué)習(xí)初步(二) 基礎(chǔ)Tensor函數(shù)

2019-11-14 11:28:57
字體:
供稿:網(wǎng)友

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

theano學(xué)習(xí)初步(二) 基礎(chǔ)Tensor函數(shù)

2016-09-06 11:26 1929人閱讀 評(píng)論(0) 收藏 舉報(bào) 分類:

目錄(?)[+]

本文來自于官方文檔

Creation(聲明)

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

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

Constructors with optional dtype(用dtype參數(shù)進(jìn)行聲明)

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

返回一個(gè)0維的numpy.ndarray

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

返回一個(gè)1維的numpy.ndarray

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

返回一個(gè)2維的numpy.ndarray,但是行數(shù)保證是1。

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

返回一個(gè)2維的numpy.ndarray,但是列數(shù)保證是1。

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

返回一個(gè)2維的numpy.ndarray

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

返回一個(gè)3維的numpy.ndarray

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

返回一個(gè)4維的numpy.ndarray

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

上文說的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(一般的類型聲明)

如果你想要?jiǎng)?chuàng)建一個(gè)非標(biāo)準(zhǔn)的類型,那么就只能創(chuàng)造一個(gè)你自己定義的TensorType。你需要將dtypebroadcasting pattern傳入聲明函數(shù)中。 下面的例子是,自創(chuàng)一個(gè)五維向量。

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

你也可以重構(gòu)一個(gè)已存在的類型

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

他們會(huì)很好地結(jié)合起來。

Converting from Python Objects(從Python對(duì)象中轉(zhuǎn)移)

使用的是shared()函數(shù)。

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

這個(gè)函數(shù)似乎有一些細(xì)節(jié),雖然可以這么轉(zhuǎn)化,但是缺少上面聲明的一些功能。

Shaping and Shuffling

theano.tensor.shape(x)11

返回一個(gè)lvector用于表示x的shape

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

Parameters:

x (某種TensorVariable (或者是可兼容的類型)) – 要進(jìn)行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
發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 株洲县| 延津县| 玉环县| 长春市| 新宾| 合山市| 涞源县| 柳江县| 永和县| 濮阳市| 宁波市| 新乡市| 独山县| 星座| 铅山县| 昌吉市| 奇台县| 县级市| 巴中市| 诸暨市| 大田县| 滨海县| 黑山县| 太原市| 黄平县| 江源县| 广水市| 北辰区| 东阿县| 水城县| 靖边县| 陆丰市| 眉山市| 宁津县| 子长县| 醴陵市| 阆中市| 前郭尔| 罗城| 临安市| 胶南市|