MCPcopy Create free account
hub / github.com/Tencent/embedx / XInputEmbeddingLookup

Function XInputEmbeddingLookup

src/model/encoder/embedding_lookup_encoder.cc:24–34  ·  view source on GitHub ↗

/ input embedding lookup functions */ / rand initialization (-1 / log(col), 1 / log(col))

Source from the content-addressed store, hash-verified

22/************************************************************************/
23// rand initialization (-1 / log(col), 1 / log(col))
24GraphNode* XInputEmbeddingLookup(const std::string& prefix, GraphNode* X,
25 const GroupConfigItem3& item, int sparse) {
26 DXCHECK_THROW(X->shape().is_rank(2));
27 int tensor_type = sparse ? TENSOR_TYPE_SRM : TENSOR_TYPE_TSR;
28 int item_k = item.embedding_row + item.embedding_col;
29 auto* W =
30 GetVariable(prefix + "W", Shape(item.embedding_row, item.embedding_col),
31 tensor_type, TENSOR_INITIALIZER_TYPE_RAND,
32 -1.0 / std::log(item_k), 1.0 / std::log(item_k));
33 return EmbeddingLookup("", X, W);
34}
35
36// randn initialization (0, 1e-3) for graph-ctr models
37GraphNode* XInputEmbeddingLookup2(const std::string& prefix, GraphNode* X,

Callers 1

InitGraphMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected