Erreur je n'arrive à comprendre

Fermé
ozfally - Modifié le 5 oct. 2019 à 19:42
 ozfally - 5 oct. 2019 à 21:04
Bonjour,
J'ai un soucis avec mon programme depuis il m'affiche une erreur qu je ne comprend pas vraiment. Besoin d'un coup de pouce:

# Descente de gradient stochastique


for l in range(K):
    w = w0[1]
    for k in range(niter):
        i = np.random.randint(M) #je tire i aleatoirement
        
        t_w[k] = w 
        atemp = w
        w = w + rho[k]/M*np.sum(X[i]*(y[i] - l(X,w)) 
        cout[k] = L(w)
    axes.plot(t_w)
    axes.set_title('valeur de w au cours des itérations, pour 30 initialisations différentes')
    axes2.plot(np.log(cout))
    axes2.set_title('log(L(w)) au cours des itérations, pour 30 initialisations différentes')
plt.show()          



Configuration: Windows / Chrome 77.0.3865.90

3 réponses

yg_be Messages postés 22707 Date d'inscription lundi 9 juin 2008 Statut Contributeur Dernière intervention 19 avril 2024 1 471
5 oct. 2019 à 20:50
bonjour, le message d'erreur est-il secret?
0
File "<ipython-input-179-f18987b5f2b7>", line 17
cout[k] = L(w)
^
SyntaxError: invalid syntax
0
yg_be Messages postés 22707 Date d'inscription lundi 9 juin 2008 Statut Contributeur Dernière intervention 19 avril 2024 1 471
5 oct. 2019 à 20:57
que sont cout et L?
0
L = lambda w : -1/(X.shape[0])*np.sum(y*log(l(X,w)) + (1 - y)*log(1-l(X,w))) # la fonction perte L(w)

cout = np.zeros((niter,))
0