Sampler for sampling negative dst nodes of the given src nodes with edge_type. Args: edge_type (string): Sample negative nodes of the source node with specified edge_type. strategy (string or list): Indicates how to sample negative edges, "random" and "in_degree"
(self,
object_type,
expand_factor,
strategy="random",
conditional=False,
**kwargs)
| 838 | strategy=strategy) |
| 839 | |
| 840 | def negative_sampler(self, |
| 841 | object_type, |
| 842 | expand_factor, |
| 843 | strategy="random", |
| 844 | conditional=False, |
| 845 | **kwargs): |
| 846 | """Sampler for sampling negative dst nodes of the given src nodes |
| 847 | with edge_type. |
| 848 | |
| 849 | Args: |
| 850 | edge_type (string): Sample negative nodes of the source node with |
| 851 | specified edge_type. |
| 852 | strategy (string or list): Indicates how to sample negative edges, |
| 853 | "random" and "in_degree" are supported. |
| 854 | "random": randomly sample negative nodes. |
| 855 | "in_degree": sample negative nodes by the in degree of the target nodes. |
| 856 | expand_factor (int): Indicates how many negatives to sample for one node. |
| 857 | conditional(bool): Indicates whether sample under condition. |
| 858 | Return: |
| 859 | A 'NegativeSampler' object. |
| 860 | """ |
| 861 | if not conditional: |
| 862 | sampler = utils.strategy2op(strategy, "NegativeSampler") |
| 863 | return getattr(samplers, sampler)(self, |
| 864 | object_type, |
| 865 | expand_factor, |
| 866 | strategy=strategy) |
| 867 | else: |
| 868 | return getattr(samplers, "ConditionalNegativeSampler")(self, |
| 869 | object_type, |
| 870 | expand_factor, |
| 871 | strategy=strategy, |
| 872 | **kwargs) |
| 873 | |
| 874 | def _construct_node_source(self, path, node_type, decoder=None, option=None): |
| 875 | source = pywrap.NodeSource() |
no outgoing calls