This shows you the differences between two versions of the page.
Both sides previous revision Previous revision | |||
members:aguilloux:enseignements:lycee [2019/06/06 14:27] Agathe Guilloux |
members:aguilloux:enseignements:lycee [2019/06/06 14:27] (current) Agathe Guilloux |
||
---|---|---|---|
Line 17: | Line 17: | ||
* [[https://colab.research.google.com/drive/1dQ-pC4zzfoPSMP9Fhjc096YNrgIPMRI6 | Notebook fin (avec matrices sparses]] | * [[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]) |