Python中的x.type和type(x)有什么区别?
发布时间:2020-12-20 12:32:37 所属栏目:Python 来源:网络整理
导读:请考虑以下几行 import theano.tensor as T x = T.dscalar('x')y = T.dscalar('y')z = x+y 然后, In [15]: type(x)Out[15]: theano.tensor.var.TensorVariable 而, In [16]: x.typeOut[16]: TensorType(float64,scalar) 为什么type(x)和x.type提供两个不同的
请考虑以下几行
import theano.tensor as T x = T.dscalar('x') y = T.dscalar('y') z = x+y 然后, In [15]: type(x) Out[15]: theano.tensor.var.TensorVariable 而, In [16]: x.type Out[16]: TensorType(float64,scalar) 为什么type(x)和x.type提供两个不同的信息?他们传达了什么信息? 我也看到指的是Theano tutorial, >>> type(x) <class 'theano.tensor.basic.TensorVariable'> >>> x.type TensorType(float64,scalar) 为什么类型(x)输出在我的情况下是不同的?这些是由版本特定的实现差异引起的,这是由这种差异所表示的吗? 解决方法
theano.tensor有一个属性
type ,当你说时,你正在看
x.type 这与许多对象携带的numpy对象 另一方面, theano.tensor.var.TensorVariable 总而言之,您将属性与实际对象类型进行比较. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |