ich bekomme folgende Fehlermeldung:
Code: Alles auswählen
File "vSSGP_LVM_model.py", line 26, in __init__
lengthscale, lengthscale_p = T.dvector('lengthscale', 'lengthscale_p')
TypeError: __call__() takes at most 2 arguments (3 given)
Code: Alles auswählen
# To speed Theano up, create ram disk: mount -t tmpfs -o size=512m tmpfs /mnt/ramdisk
# Then use flag THEANO_FLAGS='base_compiledir=/mnt/ramdisk' python script.py
import sys; sys.path.insert(0, "../Theano"); sys.path.insert(0, "../../Theano")
import theano; import theano.tensor as T; import theano.sandbox.linalg as sT
import numpy as np
import pickle as cPickle
print('Theano version: ' + theano.__version__ + ', base compile dir: ' + theano.config.base_compiledir)
theano.config.mode = 'FAST_RUN'
theano.config.optimizer = 'fast_run'
theano.config.reoptimize_unpickled_function = False
class vSSGP_LVM:
def __init__(self, use_exact_A = False):
try:
print('Trying to load model...')
with open('model_exact_A.save' if use_exact_A else 'model.save', 'rb') as file_handle:
self.f, self.g = cPickle.load(file_handle)
print('Loaded!')
return
except:
print('Failed. Creating a new model...')
print('Setting up variables...')
X, S, MU, SIGMA, MU_A, SIGMA_A, U, b = T.dmatrices('X', 'S', 'MU', 'SIGMA', 'MU_A', 'SIGMA_A', 'U', 'b')
lengthscale, lengthscale_p = T.dvector('lengthscale', 'lengthscale_p')
sn, sf = T.dscalar('sn', 'sf')
SIGMA_trf, SIGMA_A_trf = T.log(1+T.exp(SIGMA))**2, T.log(1+T.exp(SIGMA_A))**2
sn_trf, sf_trf, lengthscale_trf, lengthscale_p_trf = T.log(1 + T.exp(sn))**2, T.log(1 + T.exp(sf))**2, T.log(1 + T.exp(lengthscale)), T.log(1 + T.exp(lengthscale_p))
(N, D), Q, M = X.shape, MU.shape[2], S.shape[1]
print('Setting up model...')
if not use_exact_A:
LL, KL, EPhi, EPhiTPhi, opt_A_mean, opt_A_cov = self.get_model(lengthscale_trf, lengthscale_p_trf, sn_trf, sf_trf,
S, MU, SIGMA_trf, MU_A, SIGMA_A_trf, U, b, X, Q, D, N, M)
else:
LL, KL_X, EPhi, EPhiTPhi, opt_A_mean, opt_A_cov = self.get_model_exact_A(lengthscale_trf, lengthscale_p_trf, sn_trf, sf_trf,
S, MU, SIGMA_trf, MU_A, SIGMA_A_trf, U, b, X, Q, D, N, M)
print('Compiling model...')
inputs = {'lengthscale': lengthscale,'lengthscale_p': lengthscale_p,'sn': sn,'sf': sf,
'S': S,'MU': MU,'SIGMA': SIGMA,'MU_A': MU_A,'SIGMA_A': SIGMA_A,'U': U,'b': b,'X': X}
z = 0.0 * sum([T.sum(v) for v in inputs.values()]) # solve a bug with derivative wrt inputs not in the graph
f = zip(['opt_A_mean', 'opt_A_cov', 'EPhi', 'EPhiTPhi', 'LL', 'KL'],
[opt_A_mean, opt_A_cov, EPhi, EPhiTPhi, LL, KL])
self.f = {n: theano.function(inputs.values(), f + z, name=n, on_unused_input='ignore') for n,f in f}
g = zip(['LL', 'KL'], [LL, KL])
wrt = {'lengthscale': lengthscale,'lengthscale_p': lengthscale_p,'sn': sn,'sf': sf,
'S': S,'MU': MU,'SIGMA': SIGMA,'MU_A': MU_A,'SIGMA_A': SIGMA_A,'U': U,'b': b}
self.g = {vn: {gn: theano.function(inputs.values(), T.grad(gv + z, vv), name='d'+gn+'_d'+vn,
on_unused_input='ignore') for gn,gv in g} for vn, vv in wrt.iteritems()}
with open('model_exact_A.save' if use_exact_A else 'model.save', 'wb') as file_handle:
print('Saving model...')
sys.setrecursionlimit(2000)
cPickle.dump([self.f, self.g], file_handle, protocol=cPickle.HIGHEST_PROTOCOL)[Codebox=python file=Unbenannt.py][/Codebox]
Romaxx