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

Method embedding_agg

graphlearn/python/data/values.py:342–360  ·  view source on GitHub ↗

Get aggregated embedding of fixed size of neighbors of batch seed nodes. The shape of neighbors embeddings is `[batch_size, num_neighbors, float_attr_num]`, after aggregation on axis=1, the shape is `[batch_size, float_attr_num]`. Args: func ("sum" | "mean" | "min" | "max

(self, func="sum")

Source from the content-addressed store, hash-verified

340 return agged
341
342 def embedding_agg(self, func="sum"):
343 """
344 Get aggregated embedding of fixed size of neighbors of batch seed nodes.
345 The shape of neighbors embeddings is
346 `[batch_size, num_neighbors, float_attr_num]`, after aggregation on axis=1,
347 the shape is `[batch_size, float_attr_num]`.
348
349 Args:
350 func ("sum" | "mean" | "min" | "max" | "prod"):
351 the built-in aggregate functions.
352 """
353 if not len(self.shape) == 2:
354 raise ValueError("embedding_agg is for Nodes with 2 dimension,"
355 "and the default aggregated dimension is axis=1")
356 segment_ids = \
357 [i for i in range(self.shape[0]) for _ in range(self.shape[1])]
358 agged = self._agg(func, segment_ids, self.shape[0])
359 return np.reshape(agged,
360 (self.shape[0], self._get_decoder().float_attr_num))
361
362class SparseNodes(Nodes, SparseBase):
363 """ SparseNodes is the returned value of full neighbor sampler which

Callers

nothing calls this directly

Calls 3

_aggMethod · 0.95
_get_decoderMethod · 0.95
reshapeMethod · 0.80

Tested by

no test coverage detected