torch_geometric
- seed_everything(seed: int)[source]
Sets the seed for generating random numbers in PyTorch,
numpyand Python.- Parameters
seed (int) – The desired seed.
- get_home_dir() str[source]
Get the cache directory used for storing all PyG-related data.
If
set_home_dir()is not called, the path is given by the environment variable$PYG_HOMEwhich defaults to"~/.cache/pyg".
- set_home_dir(path: str)[source]
Set the cache directory used for storing all PyG-related data.
- Parameters
path (str) – The path to a local folder.
- compile(model: Optional[Callable] = None, *args, **kwargs) Callable[source]
Optimizes the given PyG model/function via
torch.compile().This function has the same signature as
torch.compile()(see here), but it applies further optimization to make PyG models/functions more compiler-friendly.Specifically, it
temporarily disables the usage of the extension packages
torch_scatter,torch_sparseandpyg_libconverts all instances of
MessagePassingmodules into their jittable instances (seetorch_geometric.nn.conv.MessagePassing.jittable())
Note
Without these adjustments,
torch.compile()may currently fail to correctly optimize your PyG model. We are working on fully relying ontorch.compile()for future releases.
- 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_debugwill enable or disable the debug mode based on its argumentmode. It can be used as a context-manager or as a function.See
debugabove for more details.
- is_experimental_mode_enabled(options: Optional[Union[str, List[str]]] = None) bool[source]
Returns
Trueif the experimental mode is enabled. Seetorch_geometric.experimental_modefor 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)
- 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_modewill enable or disable the experimental mode based on its argumentmode. It can be used as a context-manager or as a function.See
experimental_modeabove for more details.