MCPcopy Create free account
hub / github.com/apache/singa / Encode

Method Encode

src/io/csv_encoder.cc:24–42  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

22namespace singa {
23
24std::string CSVEncoder::Encode(vector<Tensor>& data) {
25 CHECK_GE(data.size(), 1u);
26 size_t size = data[0].Size();
27 const float* value = data[0].data<float>();
28 std::string des = "";
29 if (data.size() == 2) {
30 const float label = (const float)data[1].data<int>()[0];
31 std::ostringstream buff;
32 buff << label;
33 des += buff.str() + ',';
34 }
35 for (size_t i = 0; i < size; i++) {
36 std::ostringstream buff;
37 buff << value[i];
38 if (i == size - 1) des += buff.str();
39 else des += buff.str() + ',';
40 }
41 return des;
42}
43} // namespace singa

Callers

nothing calls this directly

Calls 2

sizeMethod · 0.45
SizeMethod · 0.45

Tested by

no test coverage detected