diff --git a/docs/source_en/help_seeking_path.md b/docs/source_en/help_seeking_path.md new file mode 100644 index 0000000000000000000000000000000000000000..e57c6c84ac11fdae95976ae625f386400e1f122c --- /dev/null +++ b/docs/source_en/help_seeking_path.md @@ -0,0 +1,34 @@ +# Seeking Help and Support + +This document describes how to seek help and support when you encounter problems in using MindSpore. + + + +The following flowchart shows the overall help-seeking process which starts from users encountering a problem in using MindSpore and ends with they finding a proper solution. Help-seeking methods are introduced based on the flowchart. + +![solution](./images/problem_solving_process.png) + +- Website search + + - Go to the [official search page](https://www.mindspore.cn/search/en). + - When encountering a problem, search on the official website first, which is simple and efficient. + - Enter a keyword in the search box and click the search icon. The related content is displayed. + - Resolve the problem based on the search result. + + +- User group consultation + + - QQ user group number: 871543426. + - If you cannot solve the problem using the website search method and want a quick consultation, consult users in the QQ user group. + - After joining the group, discuss with other users. Technical experts in the group can also provide answers. + - Resolve the problem by asking experts or communicating with other users. + + +- Forum Help-Seeking + + - If you want a detailed solution, start a help post on the [MindSpore forum](https://bbs.huaweicloud.com/forum/forum-1076-1.html). + - To improve the speed and quality of problem solving, refer to [post suggestions](https://bbs.huaweicloud.com/forum/thread-69695-1-1.html) before posting. + - After the post is sent, a forum moderator collects the question and contacts technical experts to answer the question. The question will be resolved within three working days. + - Resolve the problem by referring to solutions provided by technical experts. + + If the expert test result shows that the MindSpore function needs to be improved, you are advised to submit an issue in the [MindSpore repository](https://gitee.com/mindspore). Issues will be resolved in later versions. \ No newline at end of file diff --git a/docs/source_en/images/problem_solving_process.png b/docs/source_en/images/problem_solving_process.png new file mode 100644 index 0000000000000000000000000000000000000000..b2fc7a9668b07af46632977cb5478e68f98e0f51 Binary files /dev/null and b/docs/source_en/images/problem_solving_process.png differ diff --git a/tutorials/notebook/README.md b/tutorials/notebook/README.md index 7c7bf55d6b69e203b9a2d511560270c607f1fd32..4c4a4d2d1d11d1704e48f96a9701c6b6021d3d10 100644 --- a/tutorials/notebook/README.md +++ b/tutorials/notebook/README.md @@ -51,6 +51,7 @@ | 教  程  名  称 | 文  件  名  称 | 教  程  类  别 | 内  容  描  述 | :----------- | :----------- | :------- |:------ | 手写数字分类识别入门体验教程 | [quick_start.ipynb](https://gitee.com/mindspore/docs/blob/master/tutorials/notebook/quick_start.ipynb) | 快速入门 | - CPU平台下从数据集到模型验证的全过程解读
- 体验教程中各功能模块的使用说明
- 数据集图形化展示
- 了解LeNet5具体结构和参数作用
- 学习使用自定义回调函数
- loss值与训练步数的变化图
- 模型精度与训练步数的变化图
- 使用模型应用到手写图片的预测与分类上 +| 线性拟合 | [linear_regression.ipynb](https://gitee.com/mindspore/docs/blob/master/tutorials/notebook/linear_regression.ipynb) | 快速入门 | - 了解线性拟合的算法原理
- 了解在MindSpore中如何实现线性拟合的算法原理
- 学习使用MindSpore实现AI训练中的正向传播和方向传播
- 可视化线性函数拟合数据的全过程。 | 加载数据集 | [loading_dataset.ipynb](https://gitee.com/mindspore/docs/blob/master/tutorials/notebook/loading_dataset.ipynb) | 使用指南 | - 学习MindSpore中加载数据集的方法
- 展示加载常用数据集的方法
- 展示加载MindRecord格式数据集的方法
- 展示加载自定义格式数据集的方法 | 将数据集转换为MindSpore数据格式 | [convert_dataset_to_mindspore_data_format.ipynb](https://gitee.com/mindspore/docs/blob/master/tutorials/notebook/convert_dataset_to_mindspore_data_format/convert_dataset_to_mindspore_data_format.ipynb) | 使用指南 | - 展示将MNIST数据集转换为MindSpore数据格式
- 展示将CSV数据集转换为MindSpore数据格式
- 展示将CIFAR-10数据集转换为MindSpore数据格式
- 展示将CIFAR-100数据集转换为MindSpore数据格式
- 展示将ImageNet数据集转换为MindSpore数据格式
- 展示用户自定义生成MindSpore数据格式 | 数据处理与数据增强 | [data_loading_enhancement.ipynb](https://gitee.com/mindspore/docs/blob/master/tutorials/notebook/data_loading_enhance/data_loading_enhancement.ipynb) | 使用指南 | - 学习MindSpore中数据处理和增强的方法
- 展示数据处理、增强方法的实际操作
- 对比展示数据处理前和处理后的效果
- 表述在数据处理、增强后的意义 diff --git a/tutorials/source_zh_cn/quick_start/linear_regression.md b/tutorials/source_zh_cn/quick_start/linear_regression.md index 148a3a01937afdd33b3f71a896257dc2985b8b96..4d8a29049d05b7bc054854e9d824b63e76aa98a0 100644 --- a/tutorials/source_zh_cn/quick_start/linear_regression.md +++ b/tutorials/source_zh_cn/quick_start/linear_regression.md @@ -40,6 +40,8 @@ 4. 定义线性拟合过程的可视化函数 5. 执行训练 +本次样例源代码请参考:。 + ## 环境准备 系统:Ubuntu18.04 @@ -103,6 +105,7 @@ plt.title("Eval_data") plt.show() ``` +输出结果: ![png](./images/linear_regression_eval_datasets.png) @@ -126,6 +129,8 @@ net = nn.Dense(1,1,TruncatedNormal(0.02),TruncatedNormal(0.02)) print("weight:", net.weight.default_input[0][0], "bias:", net.bias.default_input[0]) ``` +输出结果: + weight: -0.00034249047 bias: -0.019308656 @@ -143,6 +148,7 @@ plt.title("Eval data and net") plt.show() ``` +输出结果: ![png](./images/model_net_and_eval_datasets.png) @@ -351,7 +357,7 @@ def plot_model_and_datasets(weight, bias, data_x, data_y): 5. 图形展示模型函数和数据集。 6. 清除本轮迭代的输出`display.clear_output`,起到动态可视化效果。 -迭代完成后,输出网络模型的权重值$w和b$。 +迭代完成后,输出网络模型的权重值$w$和$b$。 ```python @@ -375,6 +381,9 @@ plot_model_and_datasets(net.weight.default_input, net.bias.default_input, data_x print("weight:", net.weight.default_input[0][0], "bias:", net.bias.default_input[0]) ``` +输出结果: + + loss_value: 0.42879593 diff --git a/tutorials/tutorial_code/linear_regression.py b/tutorials/tutorial_code/linear_regression.py new file mode 100644 index 0000000000000000000000000000000000000000..952607a19d43e1ed0e739d8f606681ab65881d60 --- /dev/null +++ b/tutorials/tutorial_code/linear_regression.py @@ -0,0 +1,74 @@ +import numpy as np +import mindspore as ms +from mindspore.ops import composite as C +from mindspore.ops import operations as P +from mindspore import Tensor +from mindspore import context +from mindspore.common.initializer import TruncatedNormal +from mindspore import nn + +context.set_context(mode=context.PYNATIVE_MODE, device_target="GPU") + +# Generating training data sets +def get_data(num, w=2.0, b=3.0): + np_x = np.ones([num, 1]) + np_y = np.ones([num, 1]) + for i in range(num): + x = np.random.uniform(-10.0, 10.0) + np_x[i] = x + noise = np.random.normal(0, 1) + y = x * w + b + noise + np_y[i]=y + return Tensor(np_x,ms.float32), Tensor(np_y,ms.float32) + +# Define the form of loss function: 1/2 * (y - y')^2 +class MyLoss(nn.loss.loss._Loss): + def __init__(self, reduction='mean'): + super().__init__(reduction) + self.square = P.Square() + def construct(self, data, label): + x = self.square(data - label) * 0.5 + return self.get_loss(x) + +# Gradient function +class GradWrap(nn.Cell): + """ GradWrap definition """ + def __init__(self, network): + super().__init__(auto_prefix=False) + self.network = network + self.weights = ms.ParameterTuple(filter(lambda x: x.requires_grad, + network.get_parameters())) + + def construct(self, data, label): + weights = self.weights + return C.GradOperation('get_by_list', get_by_list=True) \ + (self.network, weights)(data, label) + +# Initializing model functions +net = nn.Dense(1, 1, TruncatedNormal(0.02), TruncatedNormal(0.02)) + +# Loss function +criterion = MyLoss() +loss_opeartion = nn.WithLossCell(net, criterion) +train_network = GradWrap(loss_opeartion) +train_network.set_train() + +# Defining optimization +optim = nn.RMSProp(params=net.trainable_params(), learning_rate=0.02) + +# Executive Training +step_size = 200 +batch_size = 16 +for i in range(step_size): + data_x, data_y = get_data(batch_size) + grads = train_network(data_x, data_y) + optim(grads) + + # Print loss value per 10 step + if i%10 == 0: + output = net(data_x) + loss_output = criterion(output, data_y) + print(loss_output.asnumpy()) + +# Print final weight parameters +print("weight:", net.weight.default_input[0][0], "bias:", net.bias.default_input[0]) \ No newline at end of file