def mini_batch(self, hcpevec):
        cppshogi.hcpe_decode_with_value(hcpevec, self.features1,
                                        self.features2, self.move, self.result,
                                        self.value)

        z = self.result - self.value + 0.5

        return (self.torch_features1.to(device),
                self.torch_features2.to(device), self.torch_move.to(device),
                self.torch_result.to(device), torch.tensor(z).to(device),
                self.torch_value.to(device))
Ejemplo n.º 2
0
def mini_batch(hcpevec):
    features1 = np.empty((len(hcpevec), FEATURES1_NUM, 9, 9), dtype=np.float32)
    features2 = np.empty((len(hcpevec), FEATURES2_NUM, 9, 9), dtype=np.float32)
    move = np.empty((len(hcpevec)), dtype=np.int32)
    result = np.empty((len(hcpevec)), dtype=np.int32)
    value = np.empty((len(hcpevec)), dtype=np.float32)

    cppshogi.hcpe_decode_with_value(hcpevec, features1, features2, move,
                                    result, value)

    return (
        Variable(cuda.to_gpu(features1)),
        Variable(cuda.to_gpu(features2)),
    )
    def mini_batch(self, hcpevec):
        cppshogi.hcpe_decode_with_value(hcpevec, self.features1, self.features2, self.move, self.result, self.value)

        if self.device.type == 'cpu':
            return (self.torch_features1.clone(),
                    self.torch_features2.clone(),
                    self.torch_move.clone(),
                    self.torch_result.clone(),
                    self.torch_value.clone()
                    )
        else:
            return (self.torch_features1.to(self.device),
                    self.torch_features2.to(self.device),
                    self.torch_move.to(self.device),
                    self.torch_result.to(self.device),
                    self.torch_value.to(self.device)
                    )
Ejemplo n.º 4
0
def mini_batch(hcpevec):
    features1 = np.empty((len(hcpevec), FEATURES1_NUM, 9, 9), dtype=np.float32)
    features2 = np.empty((len(hcpevec), FEATURES2_NUM, 9, 9), dtype=np.float32)
    move = np.empty((len(hcpevec)), dtype=np.int32)
    result = np.empty((len(hcpevec)), dtype=np.float32)
    value = np.empty((len(hcpevec)), dtype=np.float32)

    cppshogi.hcpe_decode_with_value(hcpevec, features1, features2, move,
                                    result, value)

    z = result.astype(np.float32) - value + 0.5

    return (torch.tensor(features1).to(device),
            torch.tensor(features2).to(device),
            torch.tensor(move.astype(np.int64)).to(device),
            torch.tensor(result.reshape(
                (len(hcpevec), 1))).to(device), torch.tensor(z).to(device),
            torch.tensor(value.reshape((len(value), 1))).to(device))