| 48 | |
| 49 | template<OptimizerType optimizer_type> |
| 50 | __host__ __device__ |
| 51 | static void backward(Vector &head, Vector &tail, Vector &relation, |
| 52 | float margin, Float gradient, const Optimizer &optimizer, float relation_lr_multiplier = 1, |
| 53 | Float weight = 1) { |
| 54 | auto update = get_update_function<Float, optimizer_type>(); |
| 55 | FOR(i, dim) { |
| 56 | Float h = head[i]; |
| 57 | Float t = tail[i]; |
| 58 | Float r = relation[i]; |
| 59 | Float s = h + r - t > 0 ? 1 : -1; |
| 60 | head[i] -= (optimizer.*update)(h, -gradient * s, weight); |
| 61 | tail[i] -= (optimizer.*update)(t, gradient * s, weight); |
| 62 | relation[i] -= relation_lr_multiplier * (optimizer.*update)(r, -gradient * s, weight); |
| 63 | } |
| 64 | } |
| 65 | |
| 66 | template<OptimizerType optimizer_type> |
| 67 | __host__ __device__ |
nothing calls this directly
no outgoing calls
no test coverage detected