MCPcopy Create free account
hub / github.com/alibaba/graph-learn / __init__

Method __init__

graphlearn/python/data/decoder.py:29–98  ·  view source on GitHub ↗

Initialize a data source decoder. Args: weighted (boolean, Optional): Whether the data source has weights. Default is False. labeled (boolean, Optional): Whether the data source has labels. Default is False. attr_types (list, Optional): Attribute type list if

(self,
               weighted=False,
               labeled=False,
               attr_types=[],
               attr_delimiter=":",
               attr_dims=[])

Source from the content-addressed store, hash-verified

27 """
28
29 def __init__(self,
30 weighted=False,
31 labeled=False,
32 attr_types=[],
33 attr_delimiter=":",
34 attr_dims=[]):
35 """ Initialize a data source decoder.
36
37 Args:
38 weighted (boolean, Optional): Whether the data source has weights.
39 Default is False.
40 labeled (boolean, Optional): Whether the data source has labels.
41 Default is False.
42 attr_types (list, Optional): Attribute type list if attributes exist.
43 Default is None, which means no attribute exists. Each element must
44 be string, tuple or list.
45
46 Valid types like below:
47 attr_types = ['int', 'float', 'string']
48 attr_types = ['int', ('string', 10), 'string'] # 10 means bucket size
49 For ('string', 10), we will get the string and hash it into 10 buckets
50 directly. The raw attribute can by any string.
51
52 # True means multi-val splited by ',', only for string attribute
53 attr_types = ['int', ('string', 10, True)]
54
55 # 10 means bucket size
56 attr_types = ['int', ('int', 10), 'string']
57 For ('int', 10), we will cast the string to int first and then hash it
58 into 10 buckets. In this way, the raw attribute must be an integer.
59
60 When `attr_dims` is assigned, be sure that the string attribute must
61 be configured with a bucket size. Bucket size for int attribute is
62 optional, and it will be considered as a continuous attribute if bucket
63 size is not assigned.
64
65 attr_delimiter (string, Optional): The delimiter to seperate attributes.
66 Default is ':'. If attributes exist, all of them are concatenated
67 together with a delimiter in the raw storage. We need to know how to
68 parse them.
69 attr_dims (list, Optional): An integer list, the element of which
70 represents the dimension of the corresponding attribute that will be
71 encodeding to. Default is None, which means no attribute exists.
72
73 All valid configurations of attr_type and attr_dim are as shown below.
74 | attr_type |attr_dim| encoded into |
75 | --------- | -- | -------- |
76 | "string" | 8 | Dynamic bucket embedding variable, dim=8 |
77 | ("string",10) | 8 | Embedding variable, bucketsize=10, dim=8 |
78 |("string",10,True)| 8 |Sparse embedding variable, bucketsize=10,dim=8|
79 |("string",None,True)| 8| Sparse dynamic embedding variable, dim=8 |
80 | "int" |None| Continues numeric tensor |
81 | "int" | 8 | Dynamic bucket embedding variable, dim=8 |
82 | ("int",10) | 8 | Embedding variable, bucket size=10, dim=8 |
83 | "float" |None| Continues numeric tensor |
84 Note that dynamic bucket embedding variable is only supported in PAI-TF.
85 For continues numeric attribute, attr_dim should be either None or 0.
86 """

Callers

nothing calls this directly

Calls 1

_parse_attributesMethod · 0.95

Tested by

no test coverage detected