MCPcopy Create free account
hub / github.com/Tencent/embedx / GetTrainBatch

Method GetTrainBatch

src/model/instance_reader/eges_inst_reader.cc:115–153  ·  view source on GitHub ↗

/ Read batch data from file for training */ /

Source from the content-addressed store, hash-verified

113 /* Read batch data from file for training */
114 /************************************************************************/
115 bool GetTrainBatch(Instance* inst) {
116 std::vector<SeqValue> values;
117 if (!NextInstanceBatch<SeqValue>(inst, 1, &values)) {
118 return false;
119 }
120 seqs_ = Collect<SeqValue, vec_int_t>(values, &SeqValue::nodes);
121 inst_util::CheckLengthValid(seqs_);
122
123 auto& seq = seqs_[0];
124 DXCHECK(graph_client_->IndepSampleNegative(num_neg_, seq, seq,
125 &neg_nodes_list_));
126
127 // Generate context and negative nodes based on sequence data.
128 inst_util::GenerateContext(window_size_, window_size_, seq,
129 &context_nodes_list_);
130
131 // 1. Fill Instance(edge and label)
132 flow_->FillEdgeAndLabel(inst, instance_name::X_SRC_NODE_NAME,
133 instance_name::X_DST_NODE_NAME, deepx_core::Y_NAME,
134 seq, context_nodes_list_, neg_nodes_list_);
135
136 // Get unique src node to avoid repeated computation
137 Unique(seq, &nodes_);
138 flow_->FillNodeOrIndex(inst, instance_name::X_UNIQUE_NODE_NAME, nodes_,
139 nullptr);
140 flow_->FillNodeFeature(inst, instance_name::X_NODE_FEATURE_NAME, nodes_,
141 true);
142 // 3. Fill index
143 indexing_wrapper_->Clear();
144 indexing_wrapper_->BuildFrom(nodes_);
145 const auto& indexing = indexing_wrapper_->subgraph_indexing(ns_id_)[0];
146 auto* src_node_ptr =
147 &inst->get_or_insert<csr_t>(instance_name::X_SRC_NODE_NAME);
148 flow_->FillNodeOrIndex(inst, instance_name::X_SRC_ID_NAME, *src_node_ptr,
149 &indexing);
150
151 inst->set_batch(1);
152 return true;
153 }
154
155 /************************************************************************/
156 /* Read batch data from file for predicting */

Callers

nothing calls this directly

Calls 9

CheckLengthValidFunction · 0.85
GenerateContextFunction · 0.85
UniqueFunction · 0.85
BuildFromMethod · 0.80
IndepSampleNegativeMethod · 0.45
FillEdgeAndLabelMethod · 0.45
FillNodeOrIndexMethod · 0.45
FillNodeFeatureMethod · 0.45
ClearMethod · 0.45

Tested by

no test coverage detected