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

Method build_negative_sampler

include/core/solver.h:1264–1278  ·  view source on GitHub ↗

Build the alias table for negative sampling */

Source from the content-addressed store, hash-verified

1262
1263 /** Build the alias table for negative sampling */
1264 virtual void build_negative_sampler() {
1265 std::vector <Float> negative_weights;
1266 if (sampler_protocol & kHeadPartition)
1267 for (auto &&head_global_id : head_global_ids)
1268 negative_weights.push_back(std::pow(solver->graph->vertex_weights[head_global_id],
1269 solver->negative_sample_exponent));
1270 if (sampler_protocol & kTailPartition)
1271 for (auto &&tail_global_id : tail_global_ids)
1272 negative_weights.push_back(std::pow(solver->graph->vertex_weights[tail_global_id],
1273 solver->negative_sample_exponent));
1274 if (sampler_protocol & kGlobal)
1275 for (auto &&vertex_weight : solver->graph->vertex_weights)
1276 negative_weights.push_back(std::pow(vertex_weight, solver->negative_sample_exponent));
1277 negative_sampler.build(negative_weights);
1278 }
1279
1280 /** Determine and allocate all resources for the worker */
1281 void build() {

Callers

nothing calls this directly

Calls 1

buildMethod · 0.45

Tested by

no test coverage detected