自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(151)
  • 收藏
  • 关注

原创 神经网络(6)

def evaluate(self, test_data): """Return the number of test inputs for which the neural network outputs the correct result. Note that the neural network's output is assumed to

2015-05-06 17:27:24 443

原创 神经网络(5)

# output layer error is calculated as follows output_layer_error = self.cost_derivative(activations[-1], y) * sigmoid_prime_vec(zs[-1]) # backward pass # in backward pass, we calculate the

2015-05-06 17:27:01 366

原创 神经网络(2)

"""Update the network's weights and biases by applying gradient descent using backpropagation to a single mini batch.The update equations usedclarification: sigma_x(f) means sum of all f(x)w = w -

2015-05-06 17:25:19 501

原创 神经网络(4)

if test_data: n_test = len(test_data) n = len(training_data) for j in xrange(epochs): random.shuffle(training_data) mini_batches = [training_data[k:k+mini_batch_size] for k in

2015-05-06 17:24:21 450

原创 神经网络(3)

# after the for clause, we have 'sigma_x(partial derivation of weight corresponding to cost function)' as well as # sigma_x(partial derivation of bias corresponding to cost function). it leaves us

2015-05-06 17:23:56 364

原创 神经网络(1)

import numpy as npimport randomclass Network(): def __init__(self, sizes): """ :param sizes: each element in sizes represents the number of neurons in each layer. e.g. [2,3,1] re

2015-05-06 17:22:07 381

原创 af

抽象工厂好处:使得切换(创建)不同系列对象变的容易。缺点:难于扩展,要扩展必须从抽象层变化。代码package:designparttern.abstractfactory:

2014-04-21 14:40:28 357

原创 f23

def anim_highlight_box(top,left,width,height):    pygame.draw.rect(DISPLAYSURF, HIGHLIGHTCOLOR, (left - 2, top - 2, width + 4, height + 4), 1)    pygame.display.update()def anim_highlight_box_co

2012-08-02 17:36:00 324

原创 f22

class ServerThread(threading.Thread):    def __init__(self, num):        threading.Thread.__init__(self)        self._run_num = num     def run(self):        global connection,addr,Lock

2012-08-02 17:35:25 385

原创 f21

if is_win(cross,i,j):                         DISPLAYSURF.blit(YOUSUCK_SURF,YOUSUCK_RECT)                         pygame.display.update()                         pygame.time.wait(WINWAITTIMEMILL

2012-08-02 17:32:56 266

原创 f20

buf = sock.recv(1024)                    if len(buf) == 0:                         pygame.quit()                         sys.exit()                    pygame.event.set_allowed(MOUSEBUTTONUP)

2012-08-02 17:32:32 245

原创 f19

if (i,j,x,y) != (None,None,None,None): sock.send(str(i)+" " +str(j) + " " + str(x) + " " + str(y) ) Sended = True logger("client.txt","send()") cross[i][j] = WHITEPIECE pygame.event.set_blocked(MOUSEB

2012-08-02 17:32:10 273

原创 f18

if player == CLIENT:                while True:                    Sended = False                    while not Sended:                        for event in pygame.event.get():

2012-08-02 17:31:45 320

原创 f17

if is_win(cross,i,j):                                        DISPLAYSURF.blit(YOUWIN_SURF,YOUWIN_RECT)                                        pygame.display.update()

2012-08-02 17:31:19 228

原创 f16

elif event.type == MOUSEBUTTONUP:                                mousex, mousey = event.pos                                  i,j,x,y =  get_position_clicked(CROSSPOS,mousex,mousey)

2012-08-02 17:30:51 287

原创 f15

pygame.time.wait(WINWAITTIMEMILLESEC)                         pygame.quit()                         sys.exit()                     pygame.display.update()                     FPSCLOCK.tick(FPS

2012-08-02 17:29:54 250

原创 f14

if Lock == False:            print "here"            draw_origin_displaysurf()            if player == SERVER:                while True:                     buf = connection.recv(1024)

2012-08-02 17:28:04 272

原创 f13

elif event.type == MOUSEBUTTONUP:                mousex, mousey = event.pos                          if CREATEGAME_RECT.collidepoint(event.pos):                   #connection,addr = create_game(

2012-08-02 17:27:31 251

原创 f12

def main():    global FPS,BASICFONT,BASICFONTSIZE,Lock,connection,addr    mousex,mousey = 0,0    connection,addr = None,None    init_cross(cross)    init_crosspos(CROSSPOS)    #print CROSS

2012-08-02 17:26:35 276

原创 f10

if player == CLIENT:          while True:    for event in pygame.event.get():       if event.type == QUIT:    pygame.quit()                                    sys.exit()    elif event.type

2012-08-01 17:37:21 293

原创 f9

while not Sended:                                 for event in pygame.event.get():                                    if event.type == QUIT:                                        pygame.quit()

2012-08-01 17:35:56 254

原创 f8

if Lock == False:                    #i,j,x,y =  get_position_clicked(CROSSPOS,mousex,mousey)                    #if (i,j,x,y) != (None,None,None,None):                    if player == SERVER:

2012-08-01 17:32:59 286

原创 f6

def main():    global FPS,BASICFONT,BASICFONTSIZE    FPSCLOCK = pygame.time.Clock()     BASICFONT = pygame.font.Font(FONTPATH, BASICFONTSIZE)    mousex,mousey = 0,0    connection,addr = None

2012-08-01 17:31:49 254

原创 f5

def create_game():    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)    s.setsockopt(socket.SOL_SOCKET,socket.SO_REUSEADDR,1)      local_ip = get_local_ip()    #local_ip = "127.0.0.1"

2012-08-01 17:31:22 820

原创 f4

if j - 4 >= 0 and i - 4 >= 0:         x,y = i,j        print "i,j",i,j        s = 0        for z in range(5):            s += cross[x][y]            x-=1;y+=1        print "s:",s

2012-08-01 17:30:53 576

原创 f3

def around_check(cross,i,j):    #print i,j    if i+4         s = 0        for x in range(i,i+5):            s += cross[x][j]        if s == 5 or s == -5:            return True    if i

2012-08-01 17:30:17 528

原创 f2

def init_crosspos(CROSSPOS):     for i in range(NUMLINESHORIZONTAL):        center_x = BOARDLEFT + BOXSIZE + i*BOXSIZE        cols = []        for j in range(NUMLINESVERTICAL):            ce

2012-08-01 17:29:10 265

原创 f1

#coding=utf-8from pygame.locals import *from pygame import Surfaceimport pygameimport sysimport randomfrom pygame import fontimport osimport socketBLACK = (0,0,0)GRAY = (100, 100,

2012-08-01 17:28:25 303

原创 camera5

def main():    global FPSCLOCK    FPSCLOCK = pygame.time.Clock()     cam = Camera(WORLDWIDTH/4,WORLDHEIGHT/4)               world_in_cam_surf = WORLDSURF .subsurface((cam.x,cam.y,WINDOWWIDTH,W

2012-07-31 19:45:17 238

原创 camera4

if direction == DOWN:             if self.y                 print "down here"                print self.y,WORLDHEIGHT - WINDOWHEIGHT - 1                print self.player.y,WINDOWWIDTH/2

2012-07-31 19:44:50 311

原创 camera3

if direction == RIGHT:            if self.x                 print "right here"                print self.x,WORLDWIDTH - WINDOWWIDTH - 1                print self.player.x,WINDOWWIDTH/2

2012-07-31 19:44:17 300

原创 camera2

class World:    passclass Camera:    def __init__(self,x,y):        self.x = x        self.y = y    def follow(self,player):        self.player = player    def update(self,direction):

2012-07-31 19:43:04 214

原创 camera1

#coding=utf-8from pygame.locals import *from pygame import Surfaceimport pygameimport sysimport randomfrom pygame import fontimport osBLACK = (0,0,0)GRAY = (100, 100, 100)NAVYBLUE

2012-07-31 19:40:01 265

原创 sp11--cheat

def cheat(boxs):    print "cheat mode on"    cheat_move = ""    for move in reversed(ALLMOVES):        if move == LEFT:            cheat_move = RIGHT            (boxx,boxy) = (BLANK[0]-1,B

2012-07-28 16:21:07 211

原创 sp10

if lives             text_surf = init_font(FONTPATH,32,"YOU LOSE!",GREEN,BLUE)            draw_font(text_surf,DISPLAYSURF,WINDOWWIDTH/2-text_surf.get_rect().width/2,WINDOWHEIGHT/2-text_surf.get_re

2012-07-27 20:40:41 200

原创 sp9

elif event.type == KEYUP:                lives -= 1                key_pressed = True                if event.key in (K_LEFT, K_a) and is_valid_move(LEFT):                    move = LEFT

2012-07-27 20:40:10 227

原创 sp8

def main():       global FPSCLOCK,LIVES,BLANK,BASICFONT,FONTPATH,ALLMOVES    BASICFONT = pygame.font.Font(FONTPATH, BASICFONTSIZE)    FPSCLOCK = pygame.time.Clock()                mousex,mouse

2012-07-27 20:38:51 350

原创 sp7

def shuffle_boxs(boxs,num_moves):    global BLANK,ALLMOVES    moves_gen = []    ALLMOVES  = [UP,DOWN,LEFT,RIGHT]    HMOVES = [LEFT,RIGHT]    VMOVES = [UP,DOWN]    last_move = None    for

2012-07-27 20:37:36 297

原创 sp6

def is_valid_move(move):    global BLANK    if move == LEFT:        if BLANK[0] >= NUMBOXHORIZONTAL - 1:            return False    elif move == RIGHT:        if BLANK[0]             ret

2012-07-27 20:37:08 208

原创 sp4

def init_boxs_pixel_x_y_relative_BOARD():    boxs = []     for i in range(NUMBOXHORIZONTAL):        vert_boxs = []        x = BOXMARGINWIDTH        x += i * (BOXWIDTH + GAPBETBOXS)

2012-07-27 20:34:24 345

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除