示例#1
0
    def __init__(self, dim_x, dim_y, embed_size=16, hidden_layer_size=96):
        super(RRN, self).__init__()
        self.max_digit = dim_x * dim_y
        self.embed_size = embed_size
        self.hidden_layer_size = hidden_layer_size

        self.edges = sudoku_model_utils.determine_edges(dim_x, dim_y)

        self.embed_layer = nn.Embedding(self.max_digit + 1, self.embed_size)
        self.input_mlp = MLP([self.embed_size,
                              self.hidden_layer_size,
                              self.hidden_layer_size,
                              self.hidden_layer_size])

        self.f = MLP([2 * self.hidden_layer_size,
                      self.hidden_layer_size,
                      self.hidden_layer_size,
                      self.hidden_layer_size])
        self.g_mlp = MLP([2 * self.hidden_layer_size,
                          self.hidden_layer_size,
                          self.hidden_layer_size,
                          self.hidden_layer_size])
        self.g_lstm = nn.LSTM(self.hidden_layer_size, self.hidden_layer_size)
        self.r = MLP([self.hidden_layer_size,
                      self.hidden_layer_size,
                      self.hidden_layer_size,
                      self.max_digit])
示例#2
0
    def __init__(self, dim_x, dim_y, embed_size, hidden_layer_size):
        super(RelNet, self).__init__()
        self.max_digit = dim_x * dim_y
        self.embed_size = embed_size
        self.hidden_layer_size = hidden_layer_size

        self.edges = sudoku_model_utils.determine_edges(dim_x, dim_y)

        self.encoder = nn.Embedding(self.max_digit + 1, self.embed_size)
        self.embed_mlp = MLP(
            [self.embed_size + self.max_digit, self.hidden_layer_size])
        self.rel_layer = RelationalLayer(
            [self.hidden_layer_size, self.hidden_layer_size], self.edges)
        self.decode_mlp = MLP([self.hidden_layer_size, self.self.embed_size])
        self.decoder = MLP([self.embed_size, self.max_digit])