简体   繁体   English

Theano张量类型:Python

[英]Theano tensor types: Python

CODE: 码:

x=T.dscalar('x')
y=T.dscalar('y')
z=T.dscalar('z')
z=x+y
f= function([x,y],z)

UPON RUNNING: 运行后:

$ T.dscalar $ T.dscalar

TensorType(float64, scalar) TensorType(float64,标量)

$ x.type $ x.type

TensorType(float64, scalar) TensorType(float64,标量)

$ z.type $ z.type

TensorType(float64, scalar) TensorType(float64,标量)

$ x.type is T.dscalar $ x.type是T.dscalar

True <<<<<<<-------------------------------(1) 真<<<<<<< -------------------------------(1)

$ z.type is T.dscalar $ z.type是T.dscalar

False <<<<<<<-------------------------------(2) 假<<<<<<< -------------------------------(2)

Why isn't (1) & (2) same? (1)和(2)为什么不相同?

Line z = T.dscalar('z') is pointless because it's not a graph input. z = T.dscalar('z')是毫无意义的,因为它不是图形输入。 It's gets discarded when you do z=x+y . 当您执行z=x+y时,它将被丢弃。 The type object for z is constructed in make_node method of an Op, instead of just using T.dscalar . z的类型对象是在Op的make_node方法中构造的,而不仅仅是使用T.dscalar

Finally, Python is operator compares whether two object is identical rather than equal . 最后,Python is operator来比较两个对象是否相同而不是相等 If you check z.type == T.dscalar it will be True . 如果检查z.type == T.dscalar ,它将为True

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM