私の Theano 関数の 1 つは、入力を一切受け取らず、共有変数のみを使用して出力を計算します。しかし、この関数は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)