コード例 #1
0
def main() -> None:
    for comment in sub.stream.comments():
        if comment.saved:
            continue

        if is_valid_command(comment):
            comment.save()
            load.save(userdata)
コード例 #2
0
 def change_background(self):
     if self.scenery == "outside":
         self.game.fill(BLACK)
         self.sound.play()
         req_egg_text.__init__(295, 100,
                               ("Required eggs: %s" % chicken.req_egg),
                               WHITE, "helvetica", 32)
         req_egg_text.draw(gameCanvas.game)
         nightText.draw(gameCanvas.game)
         nightGame.__init__(300, 30, 250, 450, foodBarFront.width)
         pygame.display.update()
         pygame.time.wait(2000)
         self.file = pygame.image.load(
             'graphics//background2.png').convert()
         self.file2 = pygame.Surface([self.width, self.height],
                                     pygame.SRCALPHA, 32)
         timeBarFront.width += 75
         self.scenery = "inside"
     if timeBarFront.width <= 1:
         if self.scenery == "inside":
             self.game.fill(BLACK)
             self.sound.play()
             chicken.egg_highscore += chicken.egg
             if chicken.egg < chicken.req_egg:
                 if chicken.egg_highscore > load.load():
                     load.save(chicken.egg_highscore)
                 scoreText.__init__(300, 120,
                                    ("Score: %s" % chicken.egg_highscore),
                                    WHITE, "helvetica", 45)
                 scoreText.draw(gameCanvas.game)
                 highscoreText = text.Text(290, 400,
                                           ("Highscore: %s" % load.load()),
                                           WHITE, "helvetica", 45)
                 highscoreText.draw(gameCanvas.game)
                 gameOverAnim()
             else:
                 dayText.draw(gameCanvas.game)
                 chicken.egg = 0
                 chicken.req_egg += 2
                 pygame.display.update()
                 pygame.time.wait(2000)
                 self.file = pygame.image.load(
                     'graphics//background.png').convert()
                 self.file2 = pygame.image.load(
                     'graphics//hegn.png').convert_alpha()
                 timeBarFront.next_level()
                 foodBarFront.next_level()
                 timeBarFront.reset()
                 foodBarFront.reset()
                 self.scenery = "outside"
コード例 #3
0
ファイル: selfmat.py プロジェクト: tendence/ssh
import sys
import cPickle as pickle
import numpy as np

import load

if __name__ == "__main__":
    data = load.loadData("/home/liuy/obj/gist.ans.py.data.10000")
    print "loadData"
    X = np.matrix(data)
    X = X.T
    print X.shape
    mean = X.mean(1)
    X -= mean
    X2 = X * X.T

    Ml = load.loadData("/tmp/cifar.Ml")
    X2 += Ml
    print "adjust"

    print "dump var"
    print X2.shape
    load.save(X2, "/tmp/cifar.var")
    print "dump mean"
    print mean.shape
    load.save(mean, "/tmp/cifar.mean")
コード例 #4
0
ファイル: seqPL.py プロジェクト: tendence/ssh
print "size ", X.shape
Sk = Slf
zeros = np.zeros((X.shape[0], 1))
beta = max([scipy.spatial.distance.euclidean(i, zeros) for i in X0.T])
alpha = 1 / beta * 0.3
print alpha
W = []
K = 24
for i in xrange(K):
    print i, K
    Mc = eta * X * X.T
    print "Mc"
    print "filter Matrix"
    Mlf = Xlf * Slf * Xlf.T
    M = Mlf + Mc
    print "M"
    eigVal, eigVec = np.linalg.eig(M)
    wk = eigVec[0].T
    print "eig"
    Sk_tidle = Xlf.T * wk * wk.T * Xlf
    Sk1 = Sk - alpha * T_func(Sk_tidle, Sk)
    print "udpate S"
    X = X - wk * wk.T * X
    print "update X"
    Sk = Sk1  # update
    wk = wk.T
    W.extend(wk.tolist())
W = np.matrix(W)
load.save(W, "/tmp/cifar.splh.w")
コード例 #5
0
ファイル: nonor.py プロジェクト: tendence/ssh
import load
import numpy as np
import sys

if __name__ == "__main__":
    M = load.loadData("/tmp/cifar.adjustVar")
    print M.shape
    eigVal, _ = np.linalg.eig(M)
    print min(eigVal)
    rho = max(0, -min(eigVal))
    print rho
    rho *= 1.2
    if rho == 0:
        print "rho setting 0.1"
        rho = 0.1

    Q = np.eye(M.shape[0]) + 1 / rho * M

    L = np.linalg.cholesky(Q)
    U = L.T

    load.save(L, "/tmp/cifar.nonor.L")
    load.save(L, "/tmp/cifar.nonor.U")
コード例 #6
0
ファイル: nonor.py プロジェクト: Tensionwaseda/ssh
import load
import numpy as np
import sys

if __name__ == "__main__":
    M = load.loadData("/tmp/cifar.adjustVar")
    print M.shape
    eigVal, _ = np.linalg.eig(M)
    print min(eigVal)
    rho = max(0, - min(eigVal))
    print rho
    rho *= 1.2
    if rho == 0:
        print "rho setting 0.1"
        rho = 0.1

    Q = np.eye(M.shape[0]) + 1/rho *M

    L = np.linalg.cholesky(Q)
    U = L.T

    load.save(L, "/tmp/cifar.nonor.L")
    load.save(L, "/tmp/cifar.nonor.U")

コード例 #7
0
ファイル: Ml.py プロジェクト: Tensionwaseda/ssh
    Sl = Sl[idxlst, :][:, idxlst]
    return Xl, Sl

if __name__ == "__main__":
    data = load.loadData("/home/liuy/obj/gist.ans.py.data.10000")
    X = np.matrix(data)
    X = X.T
    mean = X.mean(1)
    X -= mean
    print "load X"

    train = load.loadData("/home/liuy/obj/cifar-10-batches-py/data_batch_1")
    labels = train["labels"]
    print "load Label"

    Sl = buildLabelMatrix(labels)
    print "buildLabelMatrix"
    Xl, Sl = filterMatrix(X, Sl)
    print "filterMatrix"
    print Xl.shape
    print Sl.shape

    Ml = Xl * Sl
    Ml = Ml * Xl.T
    print Ml.shape

    var = load.loadData("/tmp/cifar.var")
    adjustVar = var + Ml * conf.eta
    print "adjust", adjustVar.shape
    load.save(adjustVar, "/tmp/cifar.adjustVar")
コード例 #8
0
ファイル: hashing.py プロジェクト: Tensionwaseda/ssh
def buildNonorW():
    L = load.loadData("/tmp/cifar.nonor.L")
    U = load.loadData("/tmp/cifar.nonor.U")
    Uk = U[:, 0:conf.K]
    W = L * Uk
    return W.T

def buildOrthW():
    W = load.loadData("/tmp/cifar.north.w")
    return W[0:conf.K, :]


def buildSeqLHW():
    W = load.loadData("/tmp/cifar.splh.w")
    W = np.matrix(W)
    return W[0:conf.K, :]


if __name__ == "__main__":
    K = conf.K
    W = buildSeqLHW()

    data = load.loadData("/home/liuy/obj/gist.ans.py.data.10000")
    X = np.matrix(data)
    X = X.T
    X -= X.mean(1)

    _, col = X.shape
    hashingArray = [hashingK(W, X[:, i]) for i in xrange(col)]
    load.save(hashingArray, "/tmp/cifar.hashingArray")
コード例 #9
0
ファイル: north.py プロジェクト: tendence/ssh
import load
import numpy as np
import sys

if __name__ == "__main__":
    M = load.loadData("/tmp/cifar.adjustVar")
    print M.shape
    V, W = np.linalg.eigh(M)
    print V
    print W
    load.save(W, "/tmp/cifar.north.w")

コード例 #10
0
ファイル: Ml.py プロジェクト: tendence/ssh
    return Xl, Sl


if __name__ == "__main__":
    data = load.loadData("/home/liuy/obj/gist.ans.py.data.10000")
    X = np.matrix(data)
    X = X.T
    mean = X.mean(1)
    X -= mean
    print "load X"

    train = load.loadData("/home/liuy/obj/cifar-10-batches-py/data_batch_1")
    labels = train["labels"]
    print "load Label"

    Sl = buildLabelMatrix(labels)
    print "buildLabelMatrix"
    Xl, Sl = filterMatrix(X, Sl)
    print "filterMatrix"
    print Xl.shape
    print Sl.shape

    Ml = Xl * Sl
    Ml = Ml * Xl.T
    print Ml.shape

    var = load.loadData("/tmp/cifar.var")
    adjustVar = var + Ml * conf.eta
    print "adjust", adjustVar.shape
    load.save(adjustVar, "/tmp/cifar.adjustVar")
コード例 #11
0
ファイル: hashing.py プロジェクト: tendence/ssh
    L = load.loadData("/tmp/cifar.nonor.L")
    U = load.loadData("/tmp/cifar.nonor.U")
    Uk = U[:, 0:conf.K]
    W = L * Uk
    return W.T


def buildOrthW():
    W = load.loadData("/tmp/cifar.north.w")
    return W[0:conf.K, :]


def buildSeqLHW():
    W = load.loadData("/tmp/cifar.splh.w")
    W = np.matrix(W)
    return W[0:conf.K, :]


if __name__ == "__main__":
    K = conf.K
    W = buildSeqLHW()

    data = load.loadData("/home/liuy/obj/gist.ans.py.data.10000")
    X = np.matrix(data)
    X = X.T
    X -= X.mean(1)

    _, col = X.shape
    hashingArray = [hashingK(W, X[:, i]) for i in xrange(col)]
    load.save(hashingArray, "/tmp/cifar.hashingArray")