My code is :
for ep in range(10):
for x, y in tqdm(train_iterator.gen_batches(batch_size=64,
data_type="train")):
x_embed = embedder(tokenizer(str_lower(x)))
y_onehot = onehotter(classes_vocab(y))
cls.train_on_batch(x_embed, y_onehot)
and the result :
<ipython-input-30-3f8c38399ce9> in <module>()
2 for x, y in tqdm(train_iterator.gen_batches(batch_size=64,
3 data_type="train")):
----> 4 x_embed = embedder(tokenizer(str_lower(x)))
5 y_onehot = onehotter(classes_vocab(y))
6 cls.train_on_batch(x_embed, y_onehot)
1 frames
/usr/local/lib/python3.6/dist-packages/deeppavlov/models/preprocessors/str_lower.py in str_lower(batch)
31 return batch.lower()
32 else:
---> 33 return list(map(str_lower, batch))
TypeError: 'float' object is not iterable
I have tried to change it to ep = int [float] but this doesn't work either.
str_lower()
takes either a string as an argument or an iterable type and calls .lower()
on it. However in your code x
is of type float. So whenever list()
is called with x
as an argument it returns this error:
>>> list(3.14)
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
list(3.14)
TypeError: 'float' object is not iterable
So you either want to:
x
is a stringstr_lower(x)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.