environment.py 文件源码

python
阅读 23 收藏 0 点赞 0 评论 0

项目:harpreif 作者: harpribot 项目源码 文件源码
def __init__(self, original_image, initial_gamestate, grid_dim,
                 puzzle_pieces, image_dim, window, stride, num_channels, state_type):
        """

        :param original_image: The true output expected. It is used to give reward
        :param initial_gamestate: The start state for each episode. It is all zeros.
        :param grid_dim: The number of horizontal and vertical splits each, required to form the puzzle pieces
        :param puzzle_pieces: The dictionary of puzzle piece image as value for the puzzle_piece id as key
        :param image_dim: The dimension (row/col) of the original image. The image must be a square image.
        :param window: The window dimension for HOG based state space construction
        :param stride: The stride of the sliding window for HOG
        :param num_channels: The number of channels of the state space (= number of gradients given by HOG)
        :param state_type: 'hog' -> state is windowed HOG filter ,
                           'image' -> state is just the partially solved jigsaw image
        """
        self.state_type = state_type
        self.bins = np.array([x/float(NUM_BINS) for x in range(0, NUM_BINS, 1)])
        self.original_image = original_image
        self.jigsaw_image = np.zeros([image_dim, image_dim])
        self.initial_gamestate = initial_gamestate
        self.gamestate = initial_gamestate
        self.grid_dim = grid_dim
        self.puzzle_pieces = puzzle_pieces
        self.image_dim = image_dim
        self.state_height = self.gamestate.shape[0]
        self.state_width = self.state_height
        self.window = tuple(window)
        self.num_gradients = num_channels
        self.stride = stride
        self.action = None
        self.jigsaw_id_to_placed_location = dict()
        self.placed_location_to_jigsaw_id = dict()
        self.jigsaw_split = np.split(np.array(range(self.image_dim)), self.grid_dim)
        self.steps = 0
        self.terminal = False
        self.reward = 0.
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号