MCPcopy Create free account
hub / github.com/easy-graph/Easy-Graph / drop_hyperedges_of_group

Method drop_hyperedges_of_group

easygraph/classes/hypergraph.py:432–461  ·  view source on GitHub ↗

r"""Randomly drop hyperedges from the specified hyperedge group. This function will return a new hypergraph with non-dropped hyperedges. Args: ``group_name`` (``str``): The name of the hyperedge group. ``drop_rate`` (``float``): The drop rate of hyperedges.

(
        self, group_name: str, drop_rate: float, ord="uniform"
    )

Source from the content-addressed store, hash-verified

430 return _hg
431
432 def drop_hyperedges_of_group(
433 self, group_name: str, drop_rate: float, ord="uniform"
434 ):
435 r"""Randomly drop hyperedges from the specified hyperedge group. This function will return a new hypergraph with non-dropped hyperedges.
436
437 Args:
438 ``group_name`` (``str``): The name of the hyperedge group.
439 ``drop_rate`` (``float``): The drop rate of hyperedges.
440 ``ord`` (``str``): The order of dropping edges. Currently, only ``'uniform'`` is supported. Defaults to ``uniform``.
441 """
442 if ord == "uniform":
443 _raw_groups = {}
444 for name in self.group_names:
445 if name == group_name:
446 _raw_groups[name] = {
447 k: v
448 for k, v in self._raw_groups[name].items()
449 if random.random() > drop_rate
450 }
451 else:
452 _raw_groups[name] = self._raw_groups[name]
453 state_dict = {
454 "num_v": self.num_v,
455 "raw_groups": _raw_groups,
456 }
457 _hg = Hypergraph.from_state_dict(state_dict)
458 _hg = _hg.to(self.device)
459 else:
460 raise ValueError(f"Unknown drop order: {ord}.")
461 return _hg
462
463 # =====================================================================================
464 # properties for representation

Callers

nothing calls this directly

Calls 2

from_state_dictMethod · 0.45
toMethod · 0.45

Tested by

no test coverage detected