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

Method backward

include/instance/model/knowledge_graph.h:129–144  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

127
128 template<OptimizerType optimizer_type>
129 __host__ __device__
130 static void backward(Vector &head, Vector &tail, Vector &relation,
131 float l3_regularization, Float gradient, const Optimizer &optimizer,
132 float relation_lr_multiplier = 1, Float weight = 1) {
133 auto update = get_update_function<Float, optimizer_type>();
134 l3_regularization *= 3;
135 FOR(i, dim) {
136 Float h = head[i];
137 Float t = tail[i];
138 Float r = relation[i];
139 head[i] -= (optimizer.*update)(h, gradient * r * t + l3_regularization * abs(h) * h, weight);
140 tail[i] -= (optimizer.*update)(t, gradient * h * r + l3_regularization * abs(t) * t, weight);
141 relation[i] -= relation_lr_multiplier *
142 (optimizer.*update)(r, gradient * h * t + l3_regularization * abs(r) * r, weight);
143 }
144 }
145
146 template<OptimizerType optimizer_type>
147 __host__ __device__

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected