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

Method _build_feature_spec

graphlearn/python/data/decoder.py:117–147  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

115 return True
116
117 def _build_feature_spec(self):
118 num_attrs = len(self._attr_types)
119 numeric_types = ("float", "int")
120 embedding_types = ("int", "string")
121
122 self._fspec = FeatureSpec(num_attrs, self._weighted, self._labeled)
123
124 if not self._attr_dims:
125 self._attr_dims = [None for _ in range(num_attrs)]
126
127 if num_attrs != len(self._attr_dims):
128 raise ValueError("The size of attr_dims must be equal with attr_types.")
129
130 def check(dim, attr_type, bucket):
131 if not dim:
132 assert type_name in numeric_types and bucket_size is None, \
133 "Must assign an attr_dim for {}, and bucket_size should None." \
134 .format(type_name)
135 else:
136 assert type_name in embedding_types, \
137 "Must assign an attr_dim with None for {}".format(type_name)
138
139 for attr_type, dim in zip(self._attr_types, self._attr_dims):
140 type_name, bucket_size, is_multival = self.parse(attr_type)
141 check(dim, type_name, bucket_size)
142 if is_multival:
143 self._fspec.append_multival(bucket_size, dim, ",")
144 elif dim:
145 self._fspec.append_sparse(bucket_size, dim, type_name == "int")
146 else:
147 self._fspec.append_dense(type_name == "float")
148
149 def parse(self, attr_type):
150 if isinstance(attr_type, tuple) or isinstance(attr_type, list):

Callers 1

feature_specMethod · 0.95

Calls 5

parseMethod · 0.95
FeatureSpecClass · 0.90
append_multivalMethod · 0.80
append_sparseMethod · 0.80
append_denseMethod · 0.80

Tested by

no test coverage detected