torch_geometric

Tensor Objects

EdgeIndex

A COO edge_index tensor with additional (meta)data attached.

Functions

seed_everything(seed: int) None[source]

Sets the seed for generating random numbers in , numpy and .

Parameters:

seed (int) – The desired seed.

get_home_dir() str[source]

Get the cache directory used for storing all -related data.

If set_home_dir() is not called, the path is given by the environment variable $PYG_HOME which defaults to "~/.cache/pyg".

set_home_dir(path: str) None[source]

Set the cache directory used for storing all -related data.

Parameters:

path (str) – The path to a local folder.

Optimizes the given model/function via torch.compile(). This function has the same signature as torch.compile() (see here).

Note

torch_geometric.compile() is deprecated in favor of torch.compile().

is_debug_enabled() bool[source]

Returns True if the debug mode is enabled.

class debug[source]

Context-manager that enables the debug mode to help track down errors and separate usage errors from real bugs.

with torch_geometric.debug():
    out = model(data.x, data.edge_index)
class set_debug(mode: bool)[source]

Context-manager that sets the debug mode on or off.

set_debug will enable or disable the debug mode based on its argument mode. It can be used as a context-manager or as a function.

See debug above for more details.

is_experimental_mode_enabled(options: Optional[Union[str, List[str]]] = None) bool[source]

Returns True if the experimental mode is enabled. See torch_geometric.experimental_mode for a list of (optional) options.

class experimental_mode(options: Optional[Union[str, List[str]]] = None)[source]

Context-manager that enables the experimental mode to test new but potentially unstable features.

with torch_geometric.experimental_mode():
    out = model(data.x, data.edge_index)
Parameters:

options (str or list, optional) – Currently there are no experimental features.

class set_experimental_mode(mode: bool, options: Optional[Union[str, List[str]]] = None)[source]

Context-manager that sets the experimental mode on or off.

set_experimental_mode will enable or disable the experimental mode based on its argument mode. It can be used as a context-manager or as a function.

See experimental_mode above for more details.

disable_dynamic_shapes(required_args: List[str]) Callable[source]

A decorator that disables the usage of dynamic shapes for the given arguments, i.e., it will raise an error in case required_args are not passed and needs to be automatically inferred.