Bonjour,
Sur la base de la vidéo de Sébastien COLLET DeepLearning pour le traitement du langage avec PyTorch
Le code suivant
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/usr/bin/env python
# -*- coding: utf-8 -*-
 
# Import des librairies
# ------------------------------------------------
import torchtext            # traitement du texte
import torch
import torch.nn as nn
import torch.optim as optim # optimizer
from torchtext.data import Field, TabularDataset, BucketIterator
 
import sys
 
# Tokenization
# ------------------------------------------------
import spacy
spacy_en = spacy.load('en')
 
 
def tokenizer(text): # create a tokenizer function
    return [tok.text for tok in spacy_en.tokenizer(text)]
 
# Definition des prétraitements sur le texte
# ------------------------------------------------
TEXT = Field(sequential = True, lower=True, include_lengths = False,
                  pad_token = "<pad>", unk_token = "<unk>",
                  batch_first = True, tokenize = tokenizer)
 
LABELS = Field(sequential=False, use_vocab=False)
 
# Création des datasets
# ------------------------------------------------
train_dataset, test_dataset = TabularDataset.splits(
    path='C:/Users/et/eclipse-workspace/S_COLLET/DevoxxFR-17-04-2019/data/', format='tsv',
    train='data_train', test='data_test',
    fields=[('text', TEXT), ('labels', LABELS)])
délivre le message d'erreur OverflowError: Python int too large to convert to C long
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
---------------------------------------------------------------------------
OverflowError                             Traceback (most recent call last)
<ipython-input-20-d103382ebadc> in <module>
     34     path='C:/Users/et/eclipse-workspace/S_COLLET/DevoxxFR-17-04-2019/data/', format='tsv',
     35     train='data_train', test='data_test',
---> 36     fields=[('text', TEXT), ('labels', LABELS)])
 
~\Anaconda3\lib\site-packages\torchtext\data\dataset.py in splits(cls, path, root, train, validation, test, **kwargs)
     76             path = cls.download(root)
     77         train_data = None if train is None else cls(
---> 78             os.path.join(path, train), **kwargs)
     79         val_data = None if validation is None else cls(
     80             os.path.join(path, validation), **kwargs)
 
~\Anaconda3\lib\site-packages\torchtext\data\dataset.py in __init__(self, path, format, fields, skip_header, csv_reader_params, **kwargs)
    269                 next(reader)
    270 
--> 271             examples = [make_example(line, fields) for line in reader]
    272 
    273         if isinstance(fields, dict):
 
~\Anaconda3\lib\site-packages\torchtext\data\dataset.py in <listcomp>(.0)
    269                 next(reader)
    270 
--> 271             examples = [make_example(line, fields) for line in reader]
    272 
    273         if isinstance(fields, dict):
 
~\Anaconda3\lib\site-packages\torchtext\utils.py in unicode_csv_reader(unicode_csv_data, **kwargs)
    128             maxInt = int(maxInt / 10)
    129 
--> 130     csv.field_size_limit(sys.maxsize)
    131 
    132     if six.PY2:
 
OverflowError: Python int too large to convert to C long
Je comprend qu'il me faut définir un maxsize

Des discussions évoquent l'influence de la plateforme (je suis sous Windows 64 bit), et l'utilisation de dtype='int64' ou dtype=np.int64
Le type int utilise un C long, qui est toujours 32-bit sous Windows
Perso je ne comprends pas comment utiliser ces infos pour traiter l'erreur.
Pouvez-vous m'aiguiller SVP ?
Alain