def __init__(self, triples, num_nodes, num_negatives=1): triples_and_negatives = np.vstack( [triples, sample_negatives(triples, num_nodes, num_negatives)]) labels = torch.zeros(len(triples_and_negatives), 1) labels[:len(triples), 0] = 1 TensorDataset.__init__(self, torch.from_numpy(triples_and_negatives), labels)
def __init__(self, *tensors): Dataset.__init__(self) TorchTensorDataset.__init__(self, *tensors)
def __init__(self, triples, num_nodes): TensorDataset.__init__( self, torch.from_numpy(triples), torch.from_numpy(sample_negatives(triples, num_nodes)))