This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision Last revision Both sides next revision | ||
members:aguilloux:enseignements:lycee [2019/06/05 15:40] Agathe Guilloux |
members:aguilloux:enseignements:lycee [2019/06/06 14:27] Agathe Guilloux |
||
---|---|---|---|
Line 15: | Line 15: | ||
* [[https://drive.google.com/open?id=1JRDAUI6vZSpn8c0o7GjWHVXkUIZiqVZQ | Données train]] | * [[https://drive.google.com/open?id=1JRDAUI6vZSpn8c0o7GjWHVXkUIZiqVZQ | Données train]] | ||
* [[https://drive.google.com/open?id=1_d9RIGidy9kxmAL9uXlDWLKe9yn5LnFo | Données test]] | * [[https://drive.google.com/open?id=1_d9RIGidy9kxmAL9uXlDWLKe9yn5LnFo | Données test]] | ||
+ | * [[https://colab.research.google.com/drive/1dQ-pC4zzfoPSMP9Fhjc096YNrgIPMRI6 | Notebook fin (avec matrices sparses]] | ||
+ | # Un dictionnaire mappant des mots sur un index entier | ||
+ | |||
+ | word_index = imdb.get_word_index() | ||
+ | |||
+ | # Les premiers index sont réservés | ||
+ | word_index = {k:(v+3) for k,v in word_index.items()} | ||
+ | word_index["<PAD>"] = 0 | ||
+ | word_index["<START>"] = 1 | ||
+ | word_index["<UNK>"] = 2 # inconnu | ||
+ | word_index["<UNUSED>"] = 3 | ||
+ | |||
+ | reverse_word_index = dict([(value, key) for (key, value) in word_index.items()]) | ||
+ | |||
+ | def decode_review(text): | ||
+ | return ' '.join([reverse_word_index.get(i, '?') for i in text]) |