diff --git a/tutorials/application/source_en/nlp/sentiment_analysis.md b/tutorials/application/source_en/nlp/sentiment_analysis.md index 747c3c5c38cce59a6b51a555986337319302a148..4fff69e2e404aa90a30540505dd73ceb025bba80 100644 --- a/tutorials/application/source_en/nlp/sentiment_analysis.md +++ b/tutorials/application/source_en/nlp/sentiment_analysis.md @@ -1,5 +1,7 @@ # Using RNN for Sentiment Classification + + ## Overview Sentiment classification is a classic task in natural language processing. It is a typical classification problem. The following uses MindSpore to implement an RNN-based sentimental classification model to achieve the following effects: diff --git a/tutorials/application/source_en/nlp/sequence_labeling.md b/tutorials/application/source_en/nlp/sequence_labeling.md index 36dca46770e9fa8e85fbdda2c4bfca776c055194..d8713abfdeeb21e676984561223bf652d44600eb 100644 --- a/tutorials/application/source_en/nlp/sequence_labeling.md +++ b/tutorials/application/source_en/nlp/sequence_labeling.md @@ -1,5 +1,7 @@ # Sequence Labeling Implementation Using LSTM+CRF + + ## Overview Sequence labeling refers to the process of labeling each token for a given input sequence. Sequence labeling is usually used to extract information from text, including word segmentation, position tagging, and named entity recognition (NER). The following uses NER as an example: diff --git a/tutorials/source_en/beginner/infer.md b/tutorials/source_en/beginner/infer.md index 258617275d560ccbf017f751016f154237ffba34..1515b3b52672a5771509d6436de11a882a479167 100644 --- a/tutorials/source_en/beginner/infer.md +++ b/tutorials/source_en/beginner/infer.md @@ -323,29 +323,29 @@ The following describes how to convert the model file format: 1. Use MindSpore Lite Converter to convert the file format in Linux. [Linux-x86_64 tool download link](https://www.mindspore.cn/lite/docs/en/master/use/downloads.html) -```shell -# Download and decompress the software package and set the path of the software package. {converter_path} indicates the path of the decompressed tool package, and PACKAGE_ROOT_PATH indicates the environment variable. -export PACKAGE_ROOT_PATH={converter_path} + ```shell + # Download and decompress the software package and set the path of the software package. {converter_path} indicates the path of the decompressed tool package, and PACKAGE_ROOT_PATH indicates the environment variable. + export PACKAGE_ROOT_PATH={converter_path} -# Add the dynamic link library required by the converter to the environment variable LD_LIBRARY_PATH. -export LD_LIBRARY_PATH=${PACKAGE_ROOT_PATH}/tools/converter/lib:${LD_LIBRARY_PATH} + # Add the dynamic link library required by the converter to the environment variable LD_LIBRARY_PATH. + export LD_LIBRARY_PATH=${PACKAGE_ROOT_PATH}/tools/converter/lib:${LD_LIBRARY_PATH} -# Run the conversion command on the mindspore-lite-linux-x64/tools/converter/converter. -./converter_lite --fmk=MINDIR --modelFile=mobilenet_v2_1.0_224.mindir --outputFile=mobilenet_v2_1.0_224 -``` + # Run the conversion command on the mindspore-lite-linux-x64/tools/converter/converter. + ./converter_lite --fmk=MINDIR --modelFile=mobilenet_v2_1.0_224.mindir --outputFile=mobilenet_v2_1.0_224 + ``` 2. Use MindSpore Lite Converter to convert the file format in Windows. [Windows-x64 tool download link](https://www.mindspore.cn/lite/docs/en/master/use/downloads.html) -```shell -# Download and decompress the software package and set the path of the software package. {converter_path} indicates the path of the decompressed tool package, and PACKAGE_ROOT_PATH indicates the environment variable. -set PACKAGE_ROOT_PATH={converter_path} + ```shell + # Download and decompress the software package and set the path of the software package. {converter_path} indicates the path of the decompressed tool package, and PACKAGE_ROOT_PATH indicates the environment variable. + set PACKAGE_ROOT_PATH={converter_path} -# Add the dynamic link library required by the converter to the environment variable PATH. -set PATH=%PACKAGE_ROOT_PATH%\tools\converter\lib;%PATH% + # Add the dynamic link library required by the converter to the environment variable PATH. + set PATH=%PACKAGE_ROOT_PATH%\tools\converter\lib;%PATH% -# Run the following command in the mindspore-lite-win-x64\tools\converter\converter directory: -call converter_lite --fmk=MINDIR --modelFile=mobilenet_v2_1.0_224.mindir --outputFile=mobilenet_v2_1.0_224 -``` + # Run the following command in the mindspore-lite-win-x64\tools\converter\converter directory: + call converter_lite --fmk=MINDIR --modelFile=mobilenet_v2_1.0_224.mindir --outputFile=mobilenet_v2_1.0_224 + ``` After the conversion is successful, `CONVERT RESULT SUCCESS:0` is displayed, and the `mobilenet_v2_1.0_224.ms` file is generated in the current directory. diff --git a/tutorials/source_en/beginner/train.md b/tutorials/source_en/beginner/train.md index 167f3cde42c9be540f1798c4ebb137f8a2a18031..8a93bb10d060e922172188619f089e2a181c8036 100644 --- a/tutorials/source_en/beginner/train.md +++ b/tutorials/source_en/beginner/train.md @@ -7,8 +7,7 @@ After learning how to create a model and build a dataset in the preceding tutori ## Hyperparameters Hyperparameters can be adjusted to control the model training and optimization process. Different hyperparameter values may affect the model training and convergence speed. Currently, deep learning models are optimized using the batch stochastic gradient descent algorithm. The principle of the stochastic gradient descent algorithm is as follows: - -$$w_{t+1}=w_{t}-\eta \frac{1}{n} \sum_{x \in \mathcal{B}} \nabla l\left(x, w_{t}\right)$$ +$w_{t+1}=w_{t}-\eta \frac{1}{n} \sum_{x \in \mathcal{B}} \nabla l\left(x, w_{t}\right)$ In the formula, $n$ is the batch size, and $η$ is a learning rate. In addition, $w_{t}$ is the weight parameter in the training batch t, and $\nabla l$ is the derivative of the loss function. In addition to the gradient itself, the two factors directly determine the weight update of the model. From the perspective of the optimization itself, the two factors are the most important parameters that affect the convergence of the model performance. Generally, the following hyperparameters are defined for training: @@ -29,9 +28,7 @@ learning_rate = 1e-2 ## Loss Functions -The **loss function** is used to evaluate the difference between **predicted value** and **target value** of a model. Here, the absolute error loss function `L1Loss` is used: - -$$\text { L1 Loss Function }=\sum_{i=1}^{n}\left|y_{true}-y_{predicted}\right|$$ +The **loss function** is used to evaluate the difference between **predicted value** and **target value** of a model. Here, the absolute error loss function `L1Loss` is used: $\text { L1 Loss Function }=\sum_{i=1}^{n}\left|y_{true}-y_{predicted}\right|$ `mindspore.nn.loss` provides many common loss functions, such as `SoftmaxCrossEntropyWithLogits`, `MSELoss`, and `SmoothL1Loss`.