Learning tic-tac-toe
Recipe 41
What and how do you learn in the first place? ?? : angel:
The learner is defined by
In summary, the learner itself is normal,
Input x: Phase information (one-dimensional list with 9 elements) layer1 = sigmoid(A1x+b1) layer2 = A2layer1+b2 Teacher label y: Best move (any of integers 0-9) (How do you define that best move (unverified)) loss: hoge entropy of layer2 and y
Actually, some data is put into the learner as a set (it feels like that)
Mal
board[::-1]
Sort the list in reverse order. Reference 1: baby:
list(zip(*[board[6:9], board[3:6], board[0:3]]))
Nanikore is long. Also, isn't "\ *" used for variable length arguments? ?? : construction_worker: Reference 2 ~ 4 It seems that a is expanded by adding an asterisk "\ *" like * a.
I tried various things (I think the Lord could understand this)
Let's take a look at the list (zip (* [board [6: 9], board [3: 6], board [0: 3]])) step by step.
To make it easier to see (... ☆)
def print_board(board): #The argument is a one-dimensional list
print(' ' + str(board[0]) + ' | ' + str(board[1]) + ' | ' + str(board[2]))
#print('__________')
print(' ' + str(board[3]) + ' | ' + str(board[4]) + ' | ' + str(board[5]))
#print('__________')
print(' ' + str(board[6]) + ' | ' + str(board[7]) + ' | ' + str(board[8]))
print('\n')
def make_board(board_2d): #Convert a two-dimensional list to one-dimensional
return [value for item in board_2d for value in item]
'''
board_1d = []
for item in board_2d:
for value in item:
board_1d.append(value)
return board_1d
'''
so
return [value for item in board_2d for value in item]
See ☆ above: man_with_turban: Can be rewritten with a for statement (although it will be longer)
Recommended Posts