def _set_params(flags): """Set hyperparameters from board size. Args: flags: Flags from Argparser. Returns: An MiniGoParams instance of hyperparameters. """ params = model_params.MiniGoParams() k = utils.round_power_of_two(flags.board_size ** 2 / 3) params.num_filters = k # Number of filters in the convolution layer params.fc_width = 2 * k # Width of each fully connected layer params.num_shared_layers = flags.board_size # Number of shared trunk layers params.board_size = flags.board_size # Board size # How many positions can fit on a graphics card. 256 for 9s, 16 or 32 for 19s. if flags.batch_size is None: if flags.board_size == 9: params.batch_size = 256 else: params.batch_size = 32 else: params.batch_size = flags.batch_size return params
def _set_params_from_board_size(board_size): """Set hyperparameters from board size.""" params = model_params.MiniGoParams() k = utils.round_power_of_two(board_size**2 / 3) params.num_filters = k # Number of filters in the convolution layer params.fc_width = 2 * k # Width of each fully connected layer params.num_shared_layers = board_size # Number of shared trunk layers params.board_size = board_size # Board size # How many positions can fit on a graphics card. 256 for 9s, 16 or 32 for 19s. if FLAGS.board_size == 9: params.batch_size = 256 else: params.batch_size = 32 return params
def test_round_power_of_two(self): self.assertEqual(utils.round_power_of_two(84), 64) self.assertEqual(utils.round_power_of_two(120), 128)