torch_geometric

seed_everything(seed: int)[source]

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

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)[source]

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

Parameters

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

compile(model: Optional[Callable] = None, *args, **kwargs) Callable[source]

Optimizes the given model/function via torch.compile().

This function has the same signature as torch.compile() (see here), but it applies further optimization to make models/functions more compiler-friendly.

Specifically, it

  1. temporarily disables the usage of the extension packages torch_scatter, torch_sparse and pyg_lib

  2. converts all instances of MessagePassing modules into their jittable instances (see torch_geometric.nn.conv.MessagePassing.jittable())

Note

Without these adjustments, torch.compile() may currently fail to correctly optimize your model. We are working on fully relying on torch.compile() for future releases.

is_debug_enabled()[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.