OSDN Git Service

致命的なミス
authoryamat0jp <yamat0jp@yahoo.co.jp>
Thu, 28 Dec 2017 04:26:09 +0000 (13:26 +0900)
committeryamat0jp <yamat0jp@yahoo.co.jp>
Thu, 28 Dec 2017 04:26:09 +0000 (13:26 +0900)
シンプルに
loss関数が減り始めました

gote-model.hdf5
network.py
reversi.py
sente-model.hdf5

index d4e5fda..7040527 100644 (file)
Binary files a/gote-model.hdf5 and b/gote-model.hdf5 differ
index 6189edc..8aa21ec 100644 (file)
@@ -14,9 +14,11 @@ class  Comp():
 
         self.model1.add(Dense(50,input_shape=(64,)))
         self.model1.add(Activation('relu'))
+        self.model1.add(Dropout(0.25))
     
         self.model1.add(Dense(100))
         self.model1.add(Activation('relu'))
+        self.model1.add(Dropout(0.25))
     
         self.model1.add(Dense(64))
         self.model1.add(Activation('softmax'))
@@ -27,7 +29,9 @@ class  Comp():
             metrics=['accuracy'])
 
         self.model2.add(Dense(50,input_shape=(64,)))
-        self.model2.add(Activation('relu'))
+        self.model2.add(Activation('sigmoid'))
+        self.model2.add(Dense(100))
+        self.model2.add(Activation('sigmoid'))
         self.model2.add(Dense(64))    
         self.model2.add(Activation('softmax'))
         self.model2.compile(
@@ -50,9 +54,17 @@ class  Comp():
         for i in range(10):
             self.model1.fit(X,Y)
             res = self.model1.predict(X,1)
-            s = np.argmax(res)
-            if Y[0][s] != -1:
-                print('hit!')
+            while True:
+                s = np.argmax(res)
+                if res[0][s] == 0:
+                    s = np.argmax(Y)
+                    print('miss!')
+                elif Y[0][s] == -1:
+                    res[0][s] = 0
+                    print('next')
+                    continue
+                else:
+                    print('hit!')
                 break
         else:
             s = np.argmax(Y)
@@ -67,9 +79,17 @@ class  Comp():
         for i in range(10):
             self.model2.fit(X,Y)
             res = self.model2.predict(X,1)
-            s = np.argmax(res)
-            if Y[0][s] != -1:
-                print('hit!')
+            while True:
+                s = np.argmax(res)
+                if res[0][s] == 0:
+                    s = np.argmax(Y)
+                    print('miss!')
+                elif Y[0][s] != -1:
+                    print('hit!')
+                else:
+                    res[0][s] = 0
+                    print('next')
+                    continue
                 break
         else:
             s = np.argmax(Y)
index a6268fa..99ec1ad 100755 (executable)
@@ -122,19 +122,19 @@ class StoneGrid():
         for i in range(8):
             for j in range(8):
                 self.CalScore(stone, i, j)
-                if self.score != -1:
+                if self.score != 0:
                     if x == False:
                         x = True
                     self.arr.grid[i][j] = self.score
                     if self.score > n:
                         n = self.score
                 else:
-                    self.arr.grid[i][j] = -1
+                    self.arr.grid[i][j] = 0
         if n > 0:
             for i in range(8):
                 for j in range(8):
                     k = self.arr.grid[i][j]
-                    if k != -1:
+                    if k != 0:
                         self.arr.grid[i][j] = k / n
     
     def Start(self):       
@@ -242,7 +242,7 @@ player1 = Player()
 player2 = Player()
 index = player1
 player1.stone = black
-player1.auto = False
+player1.auto = True
 player2.auto = True
 player2.stone = white
 stone_grid = StoneGrid()
index 26bb4e5..8899d1d 100644 (file)
Binary files a/sente-model.hdf5 and b/sente-model.hdf5 differ