| 368 | |
| 369 | template<OptimizerType optimizer_type> |
| 370 | __host__ __device__ |
| 371 | static void backward(Vector &head, Vector &tail, Vector &relation, |
| 372 | float l3_regularization, Float gradient, const Optimizer &optimizer, |
| 373 | float relation_lr_multiplier = 1, Float weight = 1) { |
| 374 | auto update = get_update_function<Float, optimizer_type>(); |
| 375 | l3_regularization *= 3; |
| 376 | FOR(i, dim) { |
| 377 | int j = i ^ 1; |
| 378 | Float h = head[i]; |
| 379 | Float t = tail[j]; |
| 380 | Float r = relation[i]; |
| 381 | head[i] -= (optimizer.*update)(h, gradient * r * t + l3_regularization * abs(h) * h, weight); |
| 382 | tail[j] -= (optimizer.*update)(t, gradient * h * r + l3_regularization * abs(t) * t, weight); |
| 383 | relation[i] -= relation_lr_multiplier * |
| 384 | (optimizer.*update)(r, gradient * h * t + l3_regularization * abs(r) * r, weight); |
| 385 | } |
| 386 | } |
| 387 | |
| 388 | template<OptimizerType optimizer_type> |
| 389 | __host__ __device__ |
nothing calls this directly
no outgoing calls
no test coverage detected