如何在 Theano 中获取共享变量的名称?我发现打印它或使用 str()
可以,但这是正确的方法吗?是否有类似于 X.get_value()
的函数(例如 X.get_name()
)?
示例:
import theano as th
import numpy as np
X = th.shared(name='xx', value=np.zeros(shape=(2), dtype=th.config.floatX), borrow=True)
print(X) # print 'xx'
print(str(X) == 'xx') # print 'True'
print(X.get_value()) # print [ 0. 0.]
最佳答案
您可以通过获取x.name
来获取共享变量x
的名称。不幸的是这是not documented .
关于python - 如何在 Theano 中获取共享变量的名称?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33901908/