Пример #1
0
    part_indices = []
    for f in xrange(detector.num_features):
        II = feature.peak_local_max(np.fabs(w[...,f]), threshold_rel=0, min_distance=1, footprint=morphology.disk(3), labels=(1+(w[...,f]>0)), exclude_border=False)
        
        part_indices.append(np.hstack([II, f*np.ones((II.shape[0], 1))]))

    indices = np.concatenate(part_indices)

    if 0:
        w_p = w.copy()
        w_p[w < 0] = 0.0
        w_n = w.copy()
        w_n[w > 0] = 0.0

        indices_p = get_key_points(w_p, 4)
        indices_n = get_key_points(w_n, 4)
        
        indices = np.concatenate([indices_p, indices_n])

    #alphas, _, coefs = linear_model.lars_path(X, y, method='lar', verbose=True)

        
    
    if 0:
        loop = 0
        while True: 
            I = array_argmax(w)
            if w[I] == 0.0:
                break
Пример #2
0
            #for f in xrange(F):
            #grid.set_image(w[...,f], f, 0, vmin=-mm, vmax=mm, cmap=cm.RdBu_r)
            fn = os.path.join(plot_dir, 'plotb{}.png'.format(loop))
            #grid.save(fn, scale=6)
            plt.savefig(fn)
            os.chmod(fn, 0644)

        #np.linalg.solve(Sigma, 0.0 * np.ones(F))
        #plt.plot(new_Z)
        #end = time.time()
        #print end - start

        # Set indices
        if indices is None:
            from train_superimposed import get_key_points
            indices = get_key_points(w)

            indices_mask = np.zeros(w.shape, dtype=bool)
            for i, index in enumerate(indices):
                indices_mask[tuple(index)] = True
                #new_w[i] = w[tuple(index)]

            print 'supp shape', supp.shape
            print 'indices_mask shape', indices_mask.shape
            print 'indices shape', indices.shape
            print 'w shape', w.shape

            supp *= indices_mask

        w[~indices_mask] = 0
Пример #3
0
            #for f in xrange(F):
                #grid.set_image(w[...,f], f, 0, vmin=-mm, vmax=mm, cmap=cm.RdBu_r)
            fn = os.path.join(plot_dir, 'plotb{}.png'.format(loop))
            #grid.save(fn, scale=6)
            plt.savefig(fn)
            os.chmod(fn, 0644)

        #np.linalg.solve(Sigma, 0.0 * np.ones(F))
        #plt.plot(new_Z)
        #end = time.time()
        #print end - start

        # Set indices
        if indices is None:
            from train_superimposed import get_key_points
            indices = get_key_points(w)

            indices_mask = np.zeros(w.shape, dtype=bool)
            for i, index in enumerate(indices):
                indices_mask[tuple(index)] = True
                #new_w[i] = w[tuple(index)]

            print 'supp shape', supp.shape
            print 'indices_mask shape', indices_mask.shape
            print 'indices shape', indices.shape
            print 'w shape', w.shape

            supp *= indices_mask
            
        w[~indices_mask] = 0