MCPcopy Create free account
hub / github.com/DeepGraphLearning/graphvite / backward

Method backward

include/instance/model/knowledge_graph.h:50–64  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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__

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected