Skip to content

Commit 17fe183

Browse files
authored
Fix vocab to_token (#570)
* fix * fix
1 parent 5be07e4 commit 17fe183

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

paddlenlp/data/vocab.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,10 +200,10 @@ def to_tokens(self, indices):
200200
if not isinstance(indices, (list, tuple, np.ndarray)):
201201
indices = [indices]
202202
to_reduce = True
203-
elif isinstance(indices, (list, tuple)):
203+
if isinstance(indices, (list, tuple)):
204204
indices = np.asarray(indices)
205205

206-
if len(indices.shape) > 1:
206+
if isinstance(indices, (np.ndarray)) and len(indices.shape) > 1:
207207
raise ValueError(
208208
'Token indices is invalid. Expected 1D array, but received {}D array. '.
209209
format(len(indices.shape)))

0 commit comments

Comments
 (0)