@@ -79,9 +79,9 @@ In the IMDb dataset, the number of positive and negative samples does not vary g
### Determining the Network and Process
Currently, MindSpore GPU supports the long short-term memory (LSTM) network for NLP.
Currently, MindSpore GPU and CPU supports SentimentNet network based on the long short-term memory (LSTM) network for NLP.
1. Load the dataset in use and process data.
2. Use the LSTM network training data to generate a model.
2. Use the SentimentNet network based on LSTM training data to generate a model.
Long short-term memory (LSTM) is an artificial recurrent neural network (RNN) architecture used for processing and predicting an important event with a long interval and delay in a time sequence. For details, refer to online documentation.
3. After the model is obtained, use the validation dataset to check the accuracy of model.
...
...
@@ -102,8 +102,6 @@ import json
fromitertoolsimportchain
importnumpyasnp
fromconfigimportlstm_cfgascfg
# Install gensim with 'pip install gensim'
importgensim
importmindspore.nnasnn
importmindspore.contextascontext
...
...
@@ -116,7 +114,9 @@ from mindspore.mindrecord import FileWriter
As shown in the following output, the loss value decreases gradually with the training process and reaches about 0.249. That is, after 10 epochs of training, the accuracy of the current text analysis result is about 85%.
...
...
@@ -506,7 +516,7 @@ After 10 epochs, the accuracy on the training set converges to about 85%, and th
CheckPoint files (model files) are saved during the training. You can view all saved files in the file path.
```shell
$ ls ckpt/
$ ls ./*.ckpt
```
The output is as follows:
...
...
@@ -520,7 +530,7 @@ After 10 epochs, the accuracy on the training set converges to about 85%, and th
Use the last saved CheckPoint file to load and validate the dataset.