MCPcopy
hub / github.com/karpathy/makemore / __getitem__

Method __getitem__

makemore.py:535–543  ·  view source on GitHub ↗
(self, idx)

Source from the content-addressed store, hash-verified

533 return word
534
535 def __getitem__(self, idx):
536 word = self.words[idx]
537 ix = self.encode(word)
538 x = torch.zeros(self.max_word_length + 1, dtype=torch.long)
539 y = torch.zeros(self.max_word_length + 1, dtype=torch.long)
540 x[1:1+len(ix)] = ix
541 y[:len(ix)] = ix
542 y[len(ix)+1:] = -1 # index -1 will mask the loss at the inactive locations
543 return x, y
544
545def create_datasets(input_file):
546

Callers

nothing calls this directly

Calls 1

encodeMethod · 0.95

Tested by

no test coverage detected