MCPcopy Create free account
hub / github.com/davisking/dlib / char_based_tokenize

Function char_based_tokenize

examples/slm_basic_train_ex.cpp:60–69  ·  view source on GitHub ↗

For simplicity, we assume each line from shakespeare_text is appended, ignoring them.

Source from the content-addressed store, hash-verified

58
59// For simplicity, we assume each line from shakespeare_text is appended, ignoring them.
60std::vector<int> char_based_tokenize(const std::string& text)
61{
62 std::vector<int> tokens;
63 tokens.reserve(text.size());
64 for (const int c : text)
65 {
66 tokens.push_back(std::min(c, MAX_TOKEN_ID));
67 }
68 return tokens;
69}
70
71// Function to shuffle samples and labels in sync
72void shuffle_samples_and_labels(std::vector<matrix<int, 0, 1>>& samples, std::vector<unsigned long>& labels) {

Callers 1

mainFunction · 0.85

Calls 4

reserveMethod · 0.80
minFunction · 0.50
sizeMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected