[英]Theano TypeError: function() takes at least 1 argument (1 given)
我的Theano函数之一不接受任何输入,仅使用共享变量来计算输出。 但是此函数抛出TypeError: function() takes at least 1 argument (1 given)
。
这里是一个最小的例子:
import theano as th
import theano.tensor as T
import numpy as np
x, y = T.dscalars('x', 'y')
z = th.shared(np.zeros(2))
f1 = th.function(inputs=[x], updates=[(z, z+x)])
f2 = th.function(outputs=z)
f1(3)
print f2()
Traceback (most recent call last):
File "/home/me/temp/theano.test.py", line 9, in <module>
f2 = th.function(updates=[(z, z*z)])
TypeError: function() takes at least 1 argument (1 given)
来自: https : //stackoverflow.com/a/16782594/380038
“ theano.function()
始终需要一个输入列表。如果该函数接受0个输入(在这种情况下,则需要为输入提供一个空列表)。”
f2 = th.function(outputs=z)
必须为f2 = th.function([], outputs=z)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.