MCPcopy
hub / github.com/tensorflow/tfjs-examples / getRandomSlice

Method getRandomSlice

lstm-text-generation/data.js:182–187  ·  view source on GitHub ↗

* Get a random slice of text data. * * @returns {[string, number[]} The string and index representation of the * same slice.

()

Source from the content-addressed store, hash-verified

180 * same slice.
181 */
182 getRandomSlice() {
183 const startIndex =
184 Math.round(Math.random() * (this.textLen_ - this.sampleLen_ - 1));
185 const textSlice = this.slice_(startIndex, startIndex + this.sampleLen_);
186 return [textSlice, this.textToIndices(textSlice)];
187 }
188
189 /**
190 * Get a slice of the training text data.

Callers 4

mainFunction · 0.95
mainFunction · 0.95
generateTextFunction · 0.80
data_test.jsFile · 0.80

Calls 2

slice_Method · 0.95
textToIndicesMethod · 0.95

Tested by

no test coverage detected