print('\nReview example (x_train[12]) :\n\n',x_train[12])
print('\nIn real words :\n\n',dataset2text(x_train[12]))
```
%% Cell type:markdown id: tags:
### Save dataset and dictionary (can be usefull but not mandatory if at GRICAD or IDRIS)
%% Cell type:code id: tags:
``` python
os.makedirs('./data',mode=0o750,exist_ok=True)
withh5py.File('./data/dataset_imdb.h5','w')asf:
f.create_dataset("x_train",data=x_train)
f.create_dataset("y_train",data=y_train)
f.create_dataset("x_test",data=x_test)
f.create_dataset("y_test",data=y_test)
withopen('./data/word_index.json','w')asfp:
json.dump(word_index,fp)
withopen('./data/index_word.json','w')asfp:
json.dump(index_word,fp)
print('Saved.')
```
%% Cell type:markdown id: tags:
## Step 4 - Build the model
Few remarks :
1. We'll choose a dense vector size for the embedding output with **dense_vector_size**
2.**GlobalAveragePooling1D** do a pooling on the last dimension : (None, lx, ly) -> (None, ly)
In other words: we average the set of vectors/words of a sentence
3. L'embedding de Keras fonctionne de manière supervisée. Il s'agit d'une couche de *vocab_size* neurones vers *n_neurons* permettant de maintenir une table de vecteurs (les poids constituent les vecteurs). Cette couche ne calcule pas de sortie a la façon des couches normales, mais renvois la valeur des vecteurs. n mots => n vecteurs (ensuite empilés par le pooling)