Beispiel #1
0
 def callback(w):
     W = w.reshape((-1, 1), order='F')
     u, v, c = W[:size_u], W[size_u:size_u + size_v], W[size_u + size_v:]
     uv0 = he.khatri_rao(v, u)
     loss.append(.5 * (linalg.norm(y_train - X_train.dot(uv0)) **
                       2))
     timings.append((datetime.now() - start).total_seconds())
Beispiel #2
0
    #    verbose=False, plot=False, n_jobs=1)
    #print datetime.now() - start
    #u_obo, v = out

    print('RANK ONE CLASSIC SETTING')
    u = u0
    v = v0[:, 0]
    for i, y_train in enumerate(Y_train.T):
        pl.figure()
        y_train = y_train[:, None]
        # compute optimal point
        u0, v0 = u, v # the one from previous voxel
        u, v = he.rank_one(
                X_train, y_train, fir_length, u0=u0, v0=v0,
                verbose=1, method='TNC', rtol=1e-32)
        uv0 = he.khatri_rao(v, u)
        min_loss = .5 * (linalg.norm(y_train - X_train.dot(uv0)) ** 2)
        for solver in ('TNC', 'Newton-CG', 'L-BFGS-B', 'trust-ncg', 'CG'):
            loss = []
            timings = []
            def callback(w):
                W = w.reshape((-1, 1), order='F')
                u, v, c = W[:size_u], W[size_u:size_u + size_v], W[size_u + size_v:]
                uv0 = he.khatri_rao(v, u)
                loss.append(.5 * (linalg.norm(y_train - X_train.dot(uv0)) **
                                  2))
                timings.append((datetime.now() - start).total_seconds())
            start = datetime.now()
            u0 = canonical
            out = he.rank_one(
                X_train, y_train, fir_length, u0=u0, v0=v0,