jittor_geometric.data
Data structures and utilities.
Author: lusz Date: 2025-01-14 00:47:42 Description:
- class jittor_geometric.data.Data(x=None, edge_index=None, edge_attr=None, y=None, pos=None, normal=None, face=None, column_indices=None, row_offset=None, csr_edge_weight=None, row_indices=None, column_offset=None, csc_edge_weight=None, **kwargs)[source]
Bases:
object
A plain old python object modeling a single graph with various (optional) attributes:
- Parameters:
x (Var, optional) – Node feature matrix with shape
[num_nodes, num_node_features]
. (default:None
)edge_index (Var.int32, optional) – Graph connectivity in COO format with shape
[2, num_edges]
. (default:None
)edge_attr (Var, optional) – Edge feature matrix with shape
[num_edges, num_edge_features]
. (default:None
)y (Var, optional) – Graph or node targets with arbitrary shape. (default:
None
)pos (Var, optional) – Node position matrix with shape
[num_nodes, num_dimensions]
. (default:None
)normal (Var, optional) – Normal vector matrix with shape
[num_nodes, num_dimensions]
. (default:None
)face (Var.int32, optional) – Face adjacency matrix with shape
[3, num_faces]
. (default:None
)
The data object is not restricted to these attributes and can be extented by any other additional data.
Example:
data = Data(x=x, edge_index=edge_index) data.train_idx = jt.array([...], dtype=Var.int32) data.test_mask = jt.array([...], dtype=Var.bool)
- __init__(x=None, edge_index=None, edge_attr=None, y=None, pos=None, normal=None, face=None, column_indices=None, row_offset=None, csr_edge_weight=None, row_indices=None, column_offset=None, csc_edge_weight=None, **kwargs)[source]
- property keys
Returns all names of graph attributes.
- __iter__()[source]
Iterates over all present attributes in the data, yielding their attribute names and content.
- __call__(*keys)[source]
Iterates over all attributes
*keys
in the data, yielding their attribute names and content. If*keys
is not given this method will iterative over all present attributes.
- __cat_dim__(key, value)[source]
Returns the dimension for which
value
of attributekey
will get concatenated when creating batches.Note
This method is for internal use only, and should only be overridden if the batch concatenation process is corrupted for a specific data attribute.
- __inc__(key, value)[source]
Returns the incremental count to cumulatively increase the value of the next attribute of
key
when creating batches.Note
This method is for internal use only, and should only be overridden if the batch concatenation process is corrupted for a specific data attribute.
- property num_nodes
Returns or sets the number of nodes in the graph.
Note
The number of nodes in your data object is typically automatically inferred, e.g., when node features
x
are present. In some cases however, a graph may only be given by its edge indicesedge_index
. Jittor Geometric then guesses the number of nodes according toedge_index.max().item() + 1
, but in case there exists isolated nodes, this number has not to be correct and can therefore result in unexpected batch-wise behavior. Thus, we recommend to set the number of nodes in your data object explicitly viadata.num_nodes = ...
. You will be given a warning that requests you to do so.
- property num_edges
Returns the number of edges in the graph. For undirected graphs, this will return the number of bi-directional edges, which is double the amount of unique edges.
- property num_faces
Returns the number of faces in the mesh.
- property num_node_features
Returns the number of features per node in the graph.
- property num_features
Alias for
num_node_features
.
- property num_edge_features
Returns the number of features per edge in the graph.
- apply(func, *keys)[source]
Applies the function
func
to all Var attributes*keys
. If*keys
is not given,func
is applied to all present attributes.
- contiguous(*keys)[source]
Ensures a contiguous memory layout for all attributes
*keys
. If*keys
is not given, all present attributes are ensured to have a contiguous memory layout.
- cpu(*keys)[source]
Copies all attributes
*keys
to CPU memory. If*keys
is not given, the conversion is applied to all present attributes.
- cuda(device=None, non_blocking=False, *keys)[source]
Copies all attributes
*keys
to CUDA memory. If*keys
is not given, the conversion is applied to all present attributes.
- class jittor_geometric.data.Dataset(root=None, transform=None, pre_transform=None, pre_filter=None)[source]
Bases:
Dataset
- Parameters:
root (string, optional) – Root directory where the dataset should be saved. (optional:
None
)transform (callable, optional) – A function/transform that takes in an
torch_geometric.data.Data
object and returns a transformed version. The data object will be transformed before every access. (default:None
)pre_transform (callable, optional) – A function/transform that takes in an
jittor_geometric.data.Data
object and returns a transformed version. The data object will be transformed before being saved to disk. (default:None
)pre_filter (callable, optional) – A function that takes in an
jittor_geometric.data.Data
object and returns a boolean value, indicating whether the data object should be included in the final dataset. (default:None
)
- property raw_file_names
The name of the files to find in the
self.raw_dir
folder in order to skip the download.
- property processed_file_names
The name of the files to find in the
self.processed_dir
folder in order to skip the processing.
- property raw_dir
- property processed_dir
- property num_node_features
Returns the number of features per node in the dataset.
- property num_features
Alias for
num_node_features
.
- property num_edge_features
Returns the number of features per edge in the dataset.
- property raw_paths
The filepaths to find in order to skip the download.
- property processed_paths
The filepaths to find in the
self.processed_dir
folder in order to skip the processing.
- class jittor_geometric.data.InMemoryDataset(root=None, transform=None, pre_transform=None, pre_filter=None)[source]
Bases:
Dataset
Dataset base class for creating graph datasets which fit completely into CPU memory.
- Parameters:
root (string, optional) – Root directory where the dataset should be saved. (default:
None
)transform (callable, optional) – A function/transform that takes in an
jittor_geometric.data.Data
object and returns a transformed version. The data object will be transformed before every access. (default:None
)pre_transform (callable, optional) – A function/transform that takes in an
jittor_geometric.data.Data
object and returns a transformed version. The data object will be transformed before being saved to disk. (default:None
)pre_filter (callable, optional) – A function that takes in an
jittor_geometric.data.Data
object and returns a boolean value, indicating whether the data object should be included in the final dataset. (default:None
)
- property raw_file_names
The name of the files to find in the
self.raw_dir
folder in order to skip the download.
- property processed_file_names
The name of the files to find in the
self.processed_dir
folder in order to skip the processing.
- property num_classes
The number of classes in the dataset.
- jittor_geometric.data.download_url(url, folder, log=True)[source]
Downloads the content of an URL to a specific folder.
- jittor_geometric.data.extract_zip(path, folder, log=True)[source]
Extracts a zip archive to a specific folder.
- jittor_geometric.data.extract_gz(path, folder, log=True)[source]
Extracts a gz archive to a specific folder.
- jittor_geometric.data.extract_tar(path, folder, mode='r:gz', log=True)[source]
Extracts a tar archive to a specific folder.
- class jittor_geometric.data.CSC(row_indices=None, column_offset=None, edge_weight=None)[source]
Bases:
object
- class jittor_geometric.data.CSR(column_indices=None, row_offset=None, edge_weight=None)[source]
Bases:
object
- class jittor_geometric.data.GraphChunk(chunks, chunk_id, v_num, global_v_num, local_mask=None, local_feature=None, local_label=None)[source]
Bases:
object
- Parameters:
- __init__(chunks, chunk_id, v_num, global_v_num, local_mask=None, local_feature=None, local_label=None)[source]
- set_csr(column_indices, row_offset, edge_weight=None)[source]
Set the CSR (Compressed Sparse Row) representation of the graph. :type column_indices: :param column_indices: Column indices of the non-zero elements. :type row_offset: :param row_offset: Row offsets for the CSR format. :type edge_weight: :param edge_weight: Optional edge weights.
- class jittor_geometric.data.TemporalData(src=None, dst=None, t=None, msg=None, y=None, edge_ids=None, **kwargs)[source]
Bases:
object
- property keys
- property num_nodes
- property max_node_id
- property src_size
- property dst_size
- property num_events
- property num_edges
- class jittor_geometric.data.Batch(x=None, edge_index=None, edge_attr=None, y=None, pos=None, normal=None, face=None, column_indices=None, row_offset=None, csr_edge_weight=None, row_indices=None, column_offset=None, csc_edge_weight=None, **kwargs)[source]
Bases:
Data
A data object describing a batch of graphs as one big (disconnected) graph. Inherits from
jittor_geometric.data.Data
.- classmethod from_data_list(data_list, follow_batch=None, exclude_keys=None)[source]
Constructs a
Batch
object from a list ofData
objects. The assignment vectorbatch
is created on the fly. In addition, creates assignment vectors for each key infollow_batch
. Will exclude any keys given inexclude_keys
.
- get_example(idx)[source]
Gets the
Data
object at indexidx
. TheBatch
object must have been created viafrom_data_list()
in order to be able to reconstruct the initial object.
- property batch_size: int
Alias for
num_graphs
.
- class jittor_geometric.data.Dictionary(*, bos='[CLS]', pad='[PAD]', eos='[SEP]', unk='[UNK]', extra_special_symbols=None)[source]
Bases:
object
A mapping from symbols to consecutive integers
- __init__(*, bos='[CLS]', pad='[PAD]', eos='[SEP]', unk='[UNK]', extra_special_symbols=None)[source]
- class jittor_geometric.data.ConformerGen(**params)[source]
Bases:
object
This class designed to generate conformers for molecules represented as SMILES strings using provided parameters and configurations. The transform method uses multiprocessing to speed up the conformer generation process.
- __init__(**params)[source]
Initializes the neural network model based on the provided model name and parameters.
- Parameters:
model_name – (str) The name of the model to initialize.
params – Additional parameters for model configuration.
- Returns:
An instance of the specified neural network model.
- Raises:
ValueError – If the model name is not recognized.