Skip to content

cora

Bases: graph_dataloader

A dataloader class for the Cora dataset.

This class extends graph_dataloader to handle the Cora graph dataset, which is commonly used in graph-based machine learning research.

Attributes:

Name Type Description
data_profile dict

Metadata and download links specific to the Cora dataset.

graph graph

The loaded graph structure for the Cora dataset.

Methods:

Name Description
__init__

Initializes the dataloader for the Cora dataset.

get_train_test_idx

Generates train and test indices for the Cora dataset.

Source code in tinybig/data/graph_dataloader.py
class cora(graph_dataloader):
    """
    A dataloader class for the Cora dataset.

    This class extends `graph_dataloader` to handle the Cora graph dataset,
    which is commonly used in graph-based machine learning research.

    Attributes
    ----------
    data_profile: dict
        Metadata and download links specific to the Cora dataset.
    graph: graph_class
        The loaded graph structure for the Cora dataset.

    Methods
    -------
    __init__(name: str = 'cora', train_batch_size: int = 64, test_batch_size: int = 64, ...)
        Initializes the dataloader for the Cora dataset.
    get_train_test_idx(X: torch.Tensor = None, y: torch.Tensor = None, ...)
        Generates train and test indices for the Cora dataset.
    """
    def __init__(self, name: str = 'cora', train_batch_size: int = 64, test_batch_size: int = 64, *args, **kwargs):
        """
        Initializes the dataloader for the Cora dataset.

        Parameters
        ----------
        name: str, default = 'cora'
            The name of the dataset.
        train_batch_size: int, default = 64
            Batch size for the training dataset.
        test_batch_size: int, default = 64
            Batch size for the testing dataset.

        Returns
        -------
        None
        """
        super().__init__(data_profile=CORA_DATA_PROFILE, name=name, train_batch_size=train_batch_size, test_batch_size=test_batch_size)

    def get_train_test_idx(self, X: torch.Tensor = None, y: torch.Tensor = None, *args, **kwargs):
        """
        Generates train and test indices for the Cora dataset.

        Parameters
        ----------
        X: torch.Tensor, optional
            Node features (not used in this method).
        y: torch.Tensor, optional
            Labels (not used in this method).

        Returns
        -------
        tuple
            Train indices (`torch.LongTensor`) and test indices (`torch.LongTensor`).

        Notes
        -----
        The train indices are predefined as the first 140 nodes.
        The test indices are predefined as nodes 500 to 1499.
        """
        train_idx = torch.LongTensor(range(140))
        test_idx = torch.LongTensor(range(500, 1500))
        return train_idx, test_idx

__init__(name='cora', train_batch_size=64, test_batch_size=64, *args, **kwargs)

Initializes the dataloader for the Cora dataset.

Parameters:

Name Type Description Default
name str

The name of the dataset.

'cora'
train_batch_size int

Batch size for the training dataset.

64
test_batch_size int

Batch size for the testing dataset.

64

Returns:

Type Description
None
Source code in tinybig/data/graph_dataloader.py
def __init__(self, name: str = 'cora', train_batch_size: int = 64, test_batch_size: int = 64, *args, **kwargs):
    """
    Initializes the dataloader for the Cora dataset.

    Parameters
    ----------
    name: str, default = 'cora'
        The name of the dataset.
    train_batch_size: int, default = 64
        Batch size for the training dataset.
    test_batch_size: int, default = 64
        Batch size for the testing dataset.

    Returns
    -------
    None
    """
    super().__init__(data_profile=CORA_DATA_PROFILE, name=name, train_batch_size=train_batch_size, test_batch_size=test_batch_size)

get_train_test_idx(X=None, y=None, *args, **kwargs)

Generates train and test indices for the Cora dataset.

Parameters:

Name Type Description Default
X Tensor

Node features (not used in this method).

None
y Tensor

Labels (not used in this method).

None

Returns:

Type Description
tuple

Train indices (torch.LongTensor) and test indices (torch.LongTensor).

Notes

The train indices are predefined as the first 140 nodes. The test indices are predefined as nodes 500 to 1499.

Source code in tinybig/data/graph_dataloader.py
def get_train_test_idx(self, X: torch.Tensor = None, y: torch.Tensor = None, *args, **kwargs):
    """
    Generates train and test indices for the Cora dataset.

    Parameters
    ----------
    X: torch.Tensor, optional
        Node features (not used in this method).
    y: torch.Tensor, optional
        Labels (not used in this method).

    Returns
    -------
    tuple
        Train indices (`torch.LongTensor`) and test indices (`torch.LongTensor`).

    Notes
    -----
    The train indices are predefined as the first 140 nodes.
    The test indices are predefined as nodes 500 to 1499.
    """
    train_idx = torch.LongTensor(range(140))
    test_idx = torch.LongTensor(range(500, 1500))
    return train_idx, test_idx