Fehlermeldung

Wenn du dir nicht sicher bist, in welchem der anderen Foren du die Frage stellen sollst, dann bist du hier im Forum für allgemeine Fragen sicher richtig.
Antworten
Romaxx
User
Beiträge: 62
Registriert: Donnerstag 26. Januar 2017, 18:53

Hallo zusammen,
ich bekomme folgende Fehlermeldung:

Code: Alles auswählen

  File "vSSGP_LVM_model.py", line 64, in get_EPhi
    EPhi = (2 * sf_trf/M)**0.5 * T.exp(-0.5 * ((S_hat**2)[None,:, :] * SIGMA_trf[:, None, :]).sum(2)) * T.cos((S_hat[None,:, :] * (MU[:, None, :] - U[None, :, :])).sum(2) + b[None, :])  # N x M

  File "theano\tensor\var.py", line 556, in __getitem__
    view = self.dimshuffle(pattern)

  File "theano\tensor\var.py", line 355, in dimshuffle
    pattern)

  File "theano\tensor\elemwise.py", line 174, in __init__
    (input_broadcastable, new_order))

ValueError: ('You cannot drop a non-broadcastable dimension.', ((False, False), ('x', 0)))
Der Code:

Code: Alles auswählen

def get_EPhi(self, lengthscale_trf, lengthscale_p_trf, sf_trf, S, MU, SIGMA_trf, U, b, N, M): 
        inv_lengthscale_p_trf, inv_lengthscale_trf = 2 * np.pi * lengthscale_p_trf**-1, lengthscale_trf**-1
        S_hat = inv_lengthscale_trf * S + inv_lengthscale_p_trf # N x Q
        EPhi = (2 * sf_trf/M)**0.5 * T.exp(-0.5 * ((S_hat**2)[None,:, :] * SIGMA_trf[:, None, :]).sum(2)) * T.cos((S_hat[None,:, :] * (MU[:, None, :] - U[None, :, :])).sum(2) + b[None, :])  # N x M
        
        S_hat_U_b =  (S_hat * U).sum(1)[:,None] + b[None,:] # M x M
        big_sum_minus = S_hat_U_b - np.transpose(S_hat_U_b) # M x M
        big_sum_plus = S_hat_U_b + np.transpose(S_hat_U_b) # M x M
        S_hat_minus = S_hat[None,:,:] - S_hat[:,None,:] # M x M x Q
        S_hat_plus = S_hat[None,:,:] + S_hat[:,None,:] # M x M x Q
        
        EPhiTPhi = np.zeros((M,M))
        for i in range(0, N):       
            EPhiTPhi_temp = np.exp(-0.5 * (S_hat_minus**2 * (np.transpose(SIGMA_trf[i , :]))[None, None,:]).sum(2)) * np.cos((S_hat_minus * (np.transpose(MU[i , :]))[None, None,:]).sum(2) + big_sum_minus) + np.exp(-0.5 * (S_hat_plus**2 * (np.transpose(SIGMA_trf[i , :]))[None, None,:]).sum(2)) * np.cos((S_hat_plus * (np.transpose(MU[i , :]))[None, None,:]).sum(2) + big_sum_plus)
            EPhiTPhi = EPhiTPhi + EPhiTPhi_temp;  
            
        EPhiTPhi = (sf_trf/M) * EPhiTPhi # M x M
        
        return EPhi, EPhiTPhi
Vielen Dank für die Hilfe, Romaxx
Romaxx
User
Beiträge: 62
Registriert: Donnerstag 26. Januar 2017, 18:53

Hallo,

hat sich erledigt.

Nun ist ein anderer Fehler aufgetaucht:

Code: Alles auswählen

  File "vSSGP_LVM_model.py", line 67, in get_EPhi
    big_sum_minus = S_hat_U_b - np.transpose(S_hat_U_b) # M x M

  File "C:\Program Files\Anaconda2\lib\site-packages\numpy\core\fromnumeric.py", line 557, in transpose
    return transpose(axes)

  File "theano\tensor\var.py", line 273, in transpose
    return theano.tensor.basic.transpose(self, axes)

  File "theano\tensor\basic.py", line 3565, in transpose
    ret = DimShuffle(x.broadcastable, axes)(x)

  File "theano\tensor\elemwise.py", line 152, in __init__
    str(j), str(type(j)))

TypeError: ("DimShuffle indices must be python ints. Got: '%s' of type '%s'.", 'None', "<type 'NoneType'>")
Code:

Code: Alles auswählen

    def get_EPhi(self, lengthscale_trf, lengthscale_p_trf, sf_trf, S, MU, SIGMA_trf, U, b, N, M): 
        inv_lengthscale_p_trf, inv_lengthscale_trf = 2 * np.pi * lengthscale_p_trf**-1, lengthscale_trf**-1
        S_hat = inv_lengthscale_trf * S + inv_lengthscale_p_trf # N x Q
        EPhi = (2 * sf_trf/M)**0.5 * T.exp(-0.5 * ((S_hat**2)[None,:, :] * SIGMA_trf[:, None, :]).sum(2)) * T.cos((S_hat[None,:, :] * (MU[:, None, :] - U[None, :, :])).sum(2) + b)  # N x M
        
        S_hat_U_b =  (S_hat * U).sum(1)[:,None] + b # M x M
        big_sum_minus = S_hat_U_b - np.transpose(S_hat_U_b) # M x M
        big_sum_plus = S_hat_U_b + np.transpose(S_hat_U_b) # M x M
        S_hat_minus = S_hat[None,:,:] - S_hat[:,None,:] # M x M x Q
        S_hat_plus = S_hat[None,:,:] + S_hat[:,None,:] # M x M x Q
        
        EPhiTPhi = np.zeros((M,M))
        for i in range(0, N):       
            EPhiTPhi_temp = np.exp(-0.5 * (S_hat_minus**2 * (np.transpose(SIGMA_trf[i , :]))[None, None,:]).sum(2)) * np.cos((S_hat_minus * (np.transpose(MU[i , :]))[None, None,:]).sum(2) + big_sum_minus) + np.exp(-0.5 * (S_hat_plus**2 * (np.transpose(SIGMA_trf[i , :]))[None, None,:]).sum(2)) * np.cos((S_hat_plus * (np.transpose(MU[i , :]))[None, None,:]).sum(2) + big_sum_plus)
            EPhiTPhi = EPhiTPhi + EPhiTPhi_temp;  
            
        EPhiTPhi = (sf_trf/M) * EPhiTPhi # M x M
        
        return EPhi, EPhiTPhi
Romaxx
User
Beiträge: 62
Registriert: Donnerstag 26. Januar 2017, 18:53

Hat sich nun auch erledigt. :)
Antworten