Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion chapter_recurrent-neural-networks/text-sequence.md
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ class Vocab: #@save
return [self.__getitem__(token) for token in tokens]

def to_tokens(self, indices):
if hasattr(indices, '__len__') and len(indices) > 1:
if isinstance(indices, (list, tuple)):
return [self.idx_to_token[int(index)] for index in indices]
return self.idx_to_token[indices]

Expand Down
2 changes: 1 addition & 1 deletion d2l/jax.py
Original file line number Diff line number Diff line change
Expand Up @@ -840,7 +840,7 @@ def __getitem__(self, tokens):
return [self.__getitem__(token) for token in tokens]

def to_tokens(self, indices):
if hasattr(indices, '__len__') and len(indices) > 1:
if isinstance(indices, (list, tuple)):
return [self.idx_to_token[int(index)] for index in indices]
return self.idx_to_token[indices]

Expand Down
2 changes: 1 addition & 1 deletion d2l/mxnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -709,7 +709,7 @@ def __getitem__(self, tokens):
return [self.__getitem__(token) for token in tokens]

def to_tokens(self, indices):
if hasattr(indices, '__len__') and len(indices) > 1:
if isinstance(indices, (list, tuple)):
return [self.idx_to_token[int(index)] for index in indices]
return self.idx_to_token[indices]

Expand Down
2 changes: 1 addition & 1 deletion d2l/tensorflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -658,7 +658,7 @@ def __getitem__(self, tokens):
return [self.__getitem__(token) for token in tokens]

def to_tokens(self, indices):
if hasattr(indices, '__len__') and len(indices) > 1:
if isinstance(indices, (list, tuple)):
return [self.idx_to_token[int(index)] for index in indices]
return self.idx_to_token[indices]

Expand Down
2 changes: 1 addition & 1 deletion d2l/torch.py
Original file line number Diff line number Diff line change
Expand Up @@ -700,7 +700,7 @@ def __getitem__(self, tokens):
return [self.__getitem__(token) for token in tokens]

def to_tokens(self, indices):
if hasattr(indices, '__len__') and len(indices) > 1:
if isinstance(indices, (list, tuple)):
return [self.idx_to_token[int(index)] for index in indices]
return self.idx_to_token[indices]

Expand Down
Loading