Exemple #1
0
    def collate(self, batch):
        packed = self.pack(batch, return_dict=True)
        y = np.array(
            packed.pop("y_list")) if "y" in self.dataset.signature else None

        packed["a"] = self.dataset.a
        output = to_mixed(**packed)
        if len(output) == 1:
            output = output[0]

        if y is None:
            return output
        else:
            return output, y
Exemple #2
0
    def collate(self, batch):
        packed = self.pack(batch)
        packed["a"] = self.dataset.a

        y = packed.pop("y_list", None)
        if y is not None:
            y = np.array(y)

        output = to_mixed(**packed)
        output = sp_matrices_to_sp_tensors(output)

        if len(output) == 1:
            output = output[0]

        if y is None:
            return output
        else:
            return output, y
Exemple #3
0
    def collate(self, batch):
        packed = self.pack(batch, return_dict=True)
        y = np.array(packed.pop("y_list")) if "y" in self.dataset.signature else None

        packed["a"] = self.dataset.a
        output = to_mixed(**packed)

        # Sparse matrices to SparseTensors
        output = list(output)
        for i in range(len(output)):
            if sp.issparse(output[i]):
                output[i] = sp_matrix_to_sp_tensor(output[i])
        output = tuple(output)

        if len(output) == 1:
            output = output[0]

        if y is None:
            return output
        else:
            return output, y