def main() -> None: for comment in sub.stream.comments(): if comment.saved: continue if is_valid_command(comment): comment.save() load.save(userdata)
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"
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")
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")
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")
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")
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")
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")
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")
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")
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")