graphgallery

set_seed(seed: Optional[int] = None)[source]
is_iterable(x: Any) → bool[source]

Check whether x is an iterable object except for string.

is_listlike(x: Any) → bool[source]

Check whether x is list like, e.g., Tuple, List, or Numpy object.

Parameters:x (A python object to check.) –
Returns:
Return type:True iff x is a list like sequence.
is_multiobjects(x: Any) → bool[source]

Check whether x is a list of complex objects (not integers).

Parameters:x (A python object to check.) –
Returns:
Return type:True iff x is a list of complex objects.
is_scalar(x: Any) → bool[source]

Check whether x is a scalar, an array scalar, or a 0-dim array.

Parameters:x (A python object to check.) –
Returns:
Return type:True iff x is a scalar, an array scalar, or a 0-dim array.
is_intscalar(x: Any) → bool[source]

Check whether x is an integer scalar.

Parameters:x (A python object to check.) –
Returns:
Return type:True iff x is an integer scalar (built-in or Numpy integer).
is_floatscalar(x: Any) → bool[source]

Check whether x is a float scalar.

Parameters:x (A python object to check.) –
Returns:
Return type:True iff x is a float scalar (built-in or Numpy float).
allowed_backends()[source]

Return the allowed backends.

backend_dict()[source]
backend(module_name=None)[source]

Publicly accessible method for determining the current backend.

module_name: String or ‘BackendModule’, optional.
‘torch’, PyTorchBackend, ‘pyg, etc. if not specified, return the current default backend module.

The backend module.

E.g. ‘PyTorch 1.6.0+cpu Backend’.

>>> graphgallery.backend()
'PyTorch 1.6.0+cpu Backend'
set_backend(module_name=None)[source]

Set the default backend module.

module_name: String or ‘BackendModule’, optional.
‘th’, ‘torch’, ‘pytorch’.
>>> graphgallery.backend()
'PyTorch 1.6.0+cpu Backend'

ValueError: In case of invalid value.

file_ext()[source]

Returns the checkpoint filename suffix(extension) for the training model

Returns:“.pth” by default
Return type:str
set_file_ext(ext: str)[source]

Set the filename suffix(extension)

class BackendModule(module=None)[source]

Base Backend Module Class.

alias = {}
version
name
abbr
extra_repr()[source]
device(ctx)[source]
class PyTorchBackend(module='torch')[source]
alias = {'pytorch', 'th', 'torch'}
version
name
abbr
class PyGBackend[source]
alias = {'pyg'}
version
name
abbr
extra_repr()[source]
device(ctx)[source]
class DGLBackend[source]
alias = {'dgl', 'dgl_th', 'dgl_torch'}
version
name
abbr
extra_repr()[source]
device(ctx)[source]
class CfgNode(init_dict=None, key_list=None, new_allowed=False)[source]

Our own extended version of yacs.config.CfgNode. It contains the following extra features:

  1. The merge_from_file() method supports the “_BASE_” key, which allows the new CfgNode to inherit all the attributes from the base configuration file.
  2. Keys that start with “COMPUTED_” are treated as insertion-only “computed” attributes. They can be inserted regardless of whether the CfgNode is frozen or not.
  3. With “allow_unsafe=True”, it supports pyyaml tags that evaluate expressions in config. See examples in https://pyyaml.org/wiki/PyYAMLDocumentation#yaml-tags-and-python-types Note that this may lead to arbitrary code execution: you must not load a config file from untrusted sources before manually inspecting the content of the file.
classmethod load_yaml_with_base(filename: str, allow_unsafe: bool = False) → None[source]
Just like yaml.load(open(filename)), but inherit attributes from its
_BASE_.
Parameters:
  • filename (str or file-like object) – the file name or file of the current config. Will be used to find the base config file.
  • allow_unsafe (bool) – whether to allow loading the config file with yaml.unsafe_load.
Returns:

the loaded yaml

Return type:

(dict)

merge_from_file(cfg_filename: str, allow_unsafe: bool = False) → None[source]

Merge configs from a given yaml file.

Parameters:
  • cfg_filename – the file name of the yaml config.
  • allow_unsafe – whether to allow loading the config file with yaml.unsafe_load.
merge_from_other_cfg(cfg_other: object) → Callable[[], None][source]
Parameters:cfg_other (CfgNode) – configs to merge from.
merge_from_list(cfg_list: List[object]) → Callable[[], None][source]
Parameters:cfg_list (list) – list of configs to merge from.
merge_from_dict(cfg_dict: Dict[object, object]) → Callable[[], None][source]
Parameters:cfg_dict (dict) – dict of configs to merge from.
get_registry(mapping, backend_name=None)[source]
load_models(package, mapping, backend_name=None, sub_module=None)[source]
empty_cache()[source]
max_memory()[source]

return the maximum allocated memory for all variables.

Returns:
Return type:allocate memory in bytes

Note

Not for Windows users.

gpu_memory()[source]

return the maximum allocated GPU memory

Returns:
Return type:allocated GPU memory in bytes.