test_v1.1
This commit is contained in:
@@ -1,6 +0,0 @@
|
|||||||
from tugo.encoders.base import *
|
|
||||||
#from tugo.encoders.alphago import *
|
|
||||||
#from tugo.encoders.betago import *
|
|
||||||
from tugo.encoders.oneplane import *
|
|
||||||
from tugo.encoders.sevenplane import *
|
|
||||||
from tugo.encoders.simple import *
|
|
||||||
|
|||||||
@@ -134,8 +134,3 @@ class AlphaGoEncoder(Encoder):
|
|||||||
|
|
||||||
def shape(self):
|
def shape(self):
|
||||||
return self.num_planes, self.board_height, self.board_width
|
return self.num_planes, self.board_height, self.board_width
|
||||||
|
|
||||||
|
|
||||||
def create(board_size):
|
|
||||||
return AlphaGoEncoder(board_size)
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,26 +0,0 @@
|
|||||||
import unittest
|
|
||||||
|
|
||||||
from tugo.agent.helpers import is_point_an_eye
|
|
||||||
from tugo.goboard_fast import Board, GameState, Move
|
|
||||||
from tugo.gotypes import Player, Point
|
|
||||||
from tugo.encoders.alphago import AlphaGoEncoder
|
|
||||||
|
|
||||||
|
|
||||||
class AlphaGoEncoderTest(unittest.TestCase):
|
|
||||||
def test_encoder(self):
|
|
||||||
alphago = AlphaGoEncoder()
|
|
||||||
|
|
||||||
start = GameState.new_game(19)
|
|
||||||
next_state = start.apply_move(Move.play(Point(16, 16)))
|
|
||||||
alphago.encode(next_state)
|
|
||||||
|
|
||||||
self.assertEquals(alphago.name(), 'alphago')
|
|
||||||
self.assertEquals(alphago.board_height, 19)
|
|
||||||
self.assertEquals(alphago.board_width, 19)
|
|
||||||
self.assertEquals(alphago.num_planes, 49)
|
|
||||||
self.assertEquals(alphago.shape(), (49, 19, 19))
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
unittest.main()
|
|
||||||
@@ -1,12 +1,4 @@
|
|||||||
# tag::importlib[]
|
|
||||||
import importlib
|
import importlib
|
||||||
# end::importlib[]
|
|
||||||
|
|
||||||
__all__ = [
|
|
||||||
'Encoder',
|
|
||||||
'get_encoder_by_name',
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
# tag::base_encoder[]
|
# tag::base_encoder[]
|
||||||
class Encoder:
|
class Encoder:
|
||||||
|
|||||||
@@ -1,9 +1,8 @@
|
|||||||
# tag::oneplane_imports[]
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
|
|
||||||
from tugo.encoders.base import Encoder
|
from tugo.encoders.base import Encoder
|
||||||
from tugo.goboard import Point
|
from tugo.goboard import Point
|
||||||
# end::oneplane_imports[]
|
|
||||||
|
|
||||||
|
|
||||||
# tag::oneplane_encoder[]
|
# tag::oneplane_encoder[]
|
||||||
|
|||||||
@@ -1 +0,0 @@
|
|||||||
from .sgf import *
|
|
||||||
@@ -1,6 +1 @@
|
|||||||
#from .fullyconnected import *
|
|
||||||
#from .large import *
|
|
||||||
#from .leaky import *
|
|
||||||
#from .medium import *
|
|
||||||
#from .small import *
|
|
||||||
from .alphago import *
|
from .alphago import *
|
||||||
|
|||||||
@@ -1,14 +0,0 @@
|
|||||||
from __future__ import absolute_import
|
|
||||||
from keras.layers.core import Dense, Activation, Flatten
|
|
||||||
|
|
||||||
|
|
||||||
def layers(input_shape):
|
|
||||||
return [
|
|
||||||
Dense(128, input_shape=input_shape),
|
|
||||||
Activation('relu'),
|
|
||||||
Dense(128, input_shape=input_shape),
|
|
||||||
Activation('relu'),
|
|
||||||
Flatten(),
|
|
||||||
Dense(128),
|
|
||||||
Activation('relu'),
|
|
||||||
]
|
|
||||||
@@ -1,39 +0,0 @@
|
|||||||
from __future__ import absolute_import
|
|
||||||
from keras.layers.core import Dense, Activation, Flatten
|
|
||||||
from keras.layers.convolutional import Conv2D, ZeroPadding2D
|
|
||||||
|
|
||||||
|
|
||||||
def layers(input_shape):
|
|
||||||
return [
|
|
||||||
ZeroPadding2D((3, 3), input_shape=input_shape, data_format='channels_first'),
|
|
||||||
Conv2D(64, (7, 7), padding='valid', data_format='channels_first'),
|
|
||||||
Activation('relu'),
|
|
||||||
|
|
||||||
ZeroPadding2D((2, 2), data_format='channels_first'),
|
|
||||||
Conv2D(64, (5, 5), data_format='channels_first'),
|
|
||||||
Activation('relu'),
|
|
||||||
|
|
||||||
ZeroPadding2D((2, 2), data_format='channels_first'),
|
|
||||||
Conv2D(64, (5, 5), data_format='channels_first'),
|
|
||||||
Activation('relu'),
|
|
||||||
|
|
||||||
ZeroPadding2D((2, 2), data_format='channels_first'),
|
|
||||||
Conv2D(48, (5, 5), data_format='channels_first'),
|
|
||||||
Activation('relu'),
|
|
||||||
|
|
||||||
ZeroPadding2D((2, 2), data_format='channels_first'),
|
|
||||||
Conv2D(48, (5, 5), data_format='channels_first'),
|
|
||||||
Activation('relu'),
|
|
||||||
|
|
||||||
ZeroPadding2D((2, 2), data_format='channels_first'),
|
|
||||||
Conv2D(32, (5, 5), data_format='channels_first'),
|
|
||||||
Activation('relu'),
|
|
||||||
|
|
||||||
ZeroPadding2D((2, 2), data_format='channels_first'),
|
|
||||||
Conv2D(32, (5, 5), data_format='channels_first'),
|
|
||||||
Activation('relu'),
|
|
||||||
|
|
||||||
Flatten(),
|
|
||||||
Dense(1024),
|
|
||||||
Activation('relu'),
|
|
||||||
]
|
|
||||||
@@ -1,40 +0,0 @@
|
|||||||
from __future__ import absolute_import
|
|
||||||
from keras.layers import LeakyReLU
|
|
||||||
from keras.layers.core import Dense, Flatten
|
|
||||||
from keras.layers.convolutional import Conv2D, ZeroPadding2D
|
|
||||||
|
|
||||||
|
|
||||||
def layers(input_shape):
|
|
||||||
return [
|
|
||||||
ZeroPadding2D((3, 3), input_shape=input_shape, data_format='channels_first'),
|
|
||||||
Conv2D(64, (7, 7), padding='valid', data_format='channels_first'),
|
|
||||||
LeakyReLU(),
|
|
||||||
|
|
||||||
ZeroPadding2D((2, 2), data_format='channels_first'),
|
|
||||||
Conv2D(64, (5, 5), data_format='channels_first'),
|
|
||||||
LeakyReLU(),
|
|
||||||
|
|
||||||
ZeroPadding2D((2, 2), data_format='channels_first'),
|
|
||||||
Conv2D(64, (5, 5), data_format='channels_first'),
|
|
||||||
LeakyReLU(),
|
|
||||||
|
|
||||||
ZeroPadding2D((2, 2), data_format='channels_first'),
|
|
||||||
Conv2D(48, (5, 5), data_format='channels_first'),
|
|
||||||
LeakyReLU(),
|
|
||||||
|
|
||||||
ZeroPadding2D((2, 2), data_format='channels_first'),
|
|
||||||
Conv2D(48, (5, 5), data_format='channels_first'),
|
|
||||||
LeakyReLU(),
|
|
||||||
|
|
||||||
ZeroPadding2D((2, 2), data_format='channels_first'),
|
|
||||||
Conv2D(32, (5, 5), data_format='channels_first'),
|
|
||||||
LeakyReLU(),
|
|
||||||
|
|
||||||
ZeroPadding2D((2, 2), data_format='channels_first'),
|
|
||||||
Conv2D(32, (5, 5), data_format='channels_first'),
|
|
||||||
LeakyReLU(),
|
|
||||||
|
|
||||||
Flatten(),
|
|
||||||
Dense(1024),
|
|
||||||
LeakyReLU(),
|
|
||||||
]
|
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
from __future__ import absolute_import
|
|
||||||
from keras.layers.core import Dense, Activation, Flatten
|
|
||||||
from keras.layers.convolutional import Conv2D, ZeroPadding2D
|
|
||||||
|
|
||||||
|
|
||||||
def layers(input_shape):
|
|
||||||
return [
|
|
||||||
ZeroPadding2D((2, 2), input_shape=input_shape, data_format='channels_first'),
|
|
||||||
Conv2D(64, (5, 5), padding='valid', data_format='channels_first'),
|
|
||||||
Activation('relu'),
|
|
||||||
|
|
||||||
ZeroPadding2D((2, 2), data_format='channels_first'),
|
|
||||||
Conv2D(64, (5, 5), data_format='channels_first'),
|
|
||||||
Activation('relu'),
|
|
||||||
|
|
||||||
ZeroPadding2D((1, 1), data_format='channels_first'),
|
|
||||||
Conv2D(64, (3, 3), data_format='channels_first'),
|
|
||||||
Activation('relu'),
|
|
||||||
|
|
||||||
ZeroPadding2D((1, 1), data_format='channels_first'),
|
|
||||||
Conv2D(64, (3, 3), data_format='channels_first'),
|
|
||||||
Activation('relu'),
|
|
||||||
|
|
||||||
ZeroPadding2D((1, 1), data_format='channels_first'),
|
|
||||||
Conv2D(64, (3, 3), data_format='channels_first'),
|
|
||||||
Activation('relu'),
|
|
||||||
|
|
||||||
Flatten(),
|
|
||||||
Dense(512),
|
|
||||||
Activation('relu'),
|
|
||||||
]
|
|
||||||
@@ -1,33 +0,0 @@
|
|||||||
from __future__ import absolute_import
|
|
||||||
|
|
||||||
# tag::small_network[]
|
|
||||||
from keras.layers.core import Dense, Activation, Flatten
|
|
||||||
from keras.layers.convolutional import Conv2D, ZeroPadding2D
|
|
||||||
|
|
||||||
|
|
||||||
def layers(input_shape):
|
|
||||||
return [
|
|
||||||
ZeroPadding2D(padding=3, input_shape=input_shape, data_format='channels_first'), # <1>
|
|
||||||
Conv2D(48, (7, 7), data_format='channels_first'),
|
|
||||||
Activation('relu'),
|
|
||||||
|
|
||||||
ZeroPadding2D(padding=2, data_format='channels_first'), # <2>
|
|
||||||
Conv2D(32, (5, 5), data_format='channels_first'),
|
|
||||||
Activation('relu'),
|
|
||||||
|
|
||||||
ZeroPadding2D(padding=2, data_format='channels_first'),
|
|
||||||
Conv2D(32, (5, 5), data_format='channels_first'),
|
|
||||||
Activation('relu'),
|
|
||||||
|
|
||||||
ZeroPadding2D(padding=2, data_format='channels_first'),
|
|
||||||
Conv2D(32, (5, 5), data_format='channels_first'),
|
|
||||||
Activation('relu'),
|
|
||||||
|
|
||||||
Flatten(),
|
|
||||||
Dense(512),
|
|
||||||
Activation('relu'),
|
|
||||||
]
|
|
||||||
|
|
||||||
# <1> We use zero padding layers to enlarge input images.
|
|
||||||
# <2> By using `channels_first` we specify that the input plane dimension for our features comes first.
|
|
||||||
# end::small_network[]
|
|
||||||
Reference in New Issue
Block a user