Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/347.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/http/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python ';返回的变量类型';theano.tensor.cast'';_Python_Theano - Fatal编程技术网

Python ';返回的变量类型';theano.tensor.cast'';

Python ';返回的变量类型';theano.tensor.cast'';,python,theano,Python,Theano,当输入是共享变量时,theano.tensor.cast返回的变量的确切类型是什么 例如,执行以下代码: import theano.tensor as T from theano import function, shared import numpy as np x = shared(np.array([1.1, 2.2, 3.3, 4.4, 5.5], dtype = np.float64)) y = T.cast(x, 'int32') print type(x) # <

当输入是共享变量时,
theano.tensor.cast
返回的变量的确切类型是什么

例如,执行以下代码:

import theano.tensor as T
from theano import function, shared
import numpy as np

x = shared(np.array([1.1, 2.2, 3.3, 4.4, 5.5], dtype = np.float64))
y = T.cast(x, 'int32')
print type(x)     # <class 'theano.tensor.sharedvar.TensorSharedVariable'>
print type(y)     # <class 'theano.tensor.var.TensorVariable'>

'''
however, the variable y has value like "shared variable"
'''

f = function([], y[:3])
print f()            # it shows ''[1 2 3]''
将无张量导入为T
从无导入功能,共享
将numpy作为np导入
x=共享(np.array([1.1,2.2,3.3,4.4,5.5],dtype=np.float64))
y=T.cast(x,'int32')
打印类型(x)#
打印类型(y)#
'''
但是,变量y的值类似于“共享变量”
'''
f=函数([],y[:3])
打印f()#它显示“[1 2 3]”

所以。。。。变量y的类型是什么?

使用
打印类型(y)
了解它的类型我知道,“类型(y)”的结果是y是一个张量变量,但变量y的值如上面代码所示。它应该是一个
张量变量
,我不太明白“变量y的值类似于共享变量”是什么意思使用
打印类型(y)
了解其类型我知道,“类型(y)”的结果是y是一个TensorVariable,但变量y具有上述代码所示的值。它应该是一个
TensorVariable
,我不太明白“变量y具有与共享变量类似的值”是什么意思?