| 51 | } |
| 52 | |
| 53 | Expression EmbedTarget(const vector<int>& sent, ComputationGraph& cg) { |
| 54 | m.resize(sent.size() + 2); |
| 55 | m[0] = lookup(cg, p_s, kTRG_SOS); |
| 56 | int i = 1; |
| 57 | for (auto& w : sent) |
| 58 | m[i++] = lookup(cg, p_t, w); |
| 59 | m[i] = lookup(cg, p_s, kTRG_EOS); |
| 60 | #ifdef DUMB_ADDITIVE |
| 61 | return sum(m); |
| 62 | #else |
| 63 | return sum_cols(tanh(kmh_ngram(concatenate_cols(m), 2))); |
| 64 | #endif |
| 65 | } |
| 66 | |
| 67 | }; |
| 68 |