| 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); |