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

Method forward

include/instance/model/knowledge_graph.h:454–469  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

452
453 __host__ __device__
454 static void forward(const Vector &head, const Vector &tail, const Vector &relation, Float &output, float margin) {
455 output = 0;
456 FOR(i, dim / 2) {
457 Float h_re = head[i * 2];
458 Float h_im = head[i * 2 + 1];
459 Float t_re = tail[i * 2];
460 Float t_im = tail[i * 2 + 1];
461 Float phase = relation[i];
462 Float r_re = cos(phase);
463 Float r_im = sin(phase);
464 Float distance_re = h_re * r_re - h_im * r_im - t_re;
465 Float distance_im = h_re * r_im + h_im * r_re - t_im;
466 output += sqrt(distance_re * distance_re + distance_im * distance_im);
467 }
468 output = margin - SUM(output);
469 }
470
471 template<OptimizerType optimizer_type>
472 __host__ __device__

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected