Ejemplo n.º 1
0
    img[:,:,1] = np.random.rand(*img.shape[:-1])
    img[0,0] = 3
    img[1,1] = 3
    img[3:6,3:6] = 50
    dot[4,4] = 1
    dot[5,5] = 1
    dot[0,0] = 2
    dot[1,1] = 2

    backup_image = np.copy(img)
    Counter = SVR(pMult, lMult, DENSITYBOUND, kernel = "linear", optimization =
                 "svr")
    sigma = [0]
    testimg, testdot, testmapping, testtags = Counter.prepareData(img, dot,
                                                                  sigma,
                                                                  normalize =
                                                                  False, smooth
                                                                  = True
                                                                  )
    #print "blub", testimg.shape
    #print testimg
    #print testdot, np.sum(testdot)
    boxConstraints = []
    #boxConstraints = [(12, img[:,:,:])]
    #boxConstraints = [(3, img[0:30,0:30,:])]
    #boxConstraints.reshape((-1, boxConstraints.shape[-1]))
    success = Counter.fitPrepared(testimg[testmapping,:], testdot[testmapping], testtags, epsilon = 0.000,
                                  boxConstraints = boxConstraints)
    #success = Counter.fitPrepared(testimg[indices,:], testdot[indices], testtags[:len(indices)], epsilon = 0.000)
    #print Counter.w, Counter.
    print "learning finished"