MCPcopy Create free account
hub / github.com/clab/dynet / EmbedSource

Method EmbedSource

examples/sentence-embedding/train_embed-cl.cc:38–51  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

36 }
37
38 Expression EmbedSource(const vector<int>& sent, ComputationGraph& cg) {
39 m.resize(sent.size() + 2);
40 m[0] = lookup(cg, p_s, kSRC_SOS);
41 int i = 1;
42 for (auto& w : sent)
43 m[i++] = lookup(cg, p_s, w);
44 m[i] = lookup(cg, p_s, kSRC_EOS);
45#define DUMB_ADDITIVE
46#ifdef DUMB_ADDITIVE
47 return sum(m);
48#else
49 return sum_cols(tanh(kmh_ngram(concatenate_cols(m), 2)));
50#endif
51 }
52
53 Expression EmbedTarget(const vector<int>& sent, ComputationGraph& cg) {
54 m.resize(sent.size() + 2);

Callers 1

mainFunction · 0.80

Calls 8

sumFunction · 0.85
lookupFunction · 0.50
sum_colsFunction · 0.50
tanhFunction · 0.50
kmh_ngramFunction · 0.50
concatenate_colsFunction · 0.50
resizeMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected