Xiaowu/20230530 (#804)
* update * update * update * Update 17.4 深度学习平台质量问题实证研究.md * update * up * update * update * Update 前言.md * update * update
This commit is contained in:
Родитель
3d8ec75749
Коммит
0855862c7e
|
@ -0,0 +1,29 @@
|
|||
# Copyright (c) Microsoft. All rights reserved.
|
||||
# Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
|
||||
import numpy as np
|
||||
import matplotlib.pyplot as plt
|
||||
import matplotlib as mpl
|
||||
|
||||
mpl.rcParams['font.sans-serif'] = ['SimHei']
|
||||
mpl.rcParams['axes.unicode_minus']=False
|
||||
|
||||
class CSigmoid(object):
|
||||
def forward(self, z):
|
||||
a = 1.0 / (1.0 + np.exp(-z))
|
||||
return a
|
||||
|
||||
|
||||
def Draw(start,end,func,lable1):
|
||||
z = np.linspace(start, end, 200)
|
||||
a = func.forward(z)
|
||||
|
||||
p1, = plt.plot(z,a)
|
||||
plt.grid()
|
||||
plt.xlabel("$Z$(input)")
|
||||
plt.ylabel("$A$(output)")
|
||||
plt.title(lable1)
|
||||
plt.show()
|
||||
|
||||
if __name__ == '__main__':
|
||||
Draw(-7,7,CSigmoid(),"激活函数图像")
|
|
@ -20,7 +20,7 @@ if __name__ == '__main__':
|
|||
p1, = plt.plot(a,z1)
|
||||
p2, = plt.plot(a,z2)
|
||||
plt.grid()
|
||||
plt.legend([p1,p2],["y=0","y=1"])
|
||||
plt.xlabel("a")
|
||||
plt.ylabel("Loss")
|
||||
plt.legend([p1,p2],["$y=0$","$y=1$"])
|
||||
plt.xlabel("$a$")
|
||||
plt.ylabel("loss")
|
||||
plt.show()
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
import numpy as np
|
||||
import matplotlib.pyplot as plt
|
||||
import matplotlib as mpl
|
||||
|
||||
from Activators.Relu import *
|
||||
from Activators.Elu import *
|
||||
|
@ -13,6 +14,9 @@ from Activators.Step import *
|
|||
from Activators.Tanh import *
|
||||
from Activators.BenIdentity import *
|
||||
|
||||
mpl.rcParams['font.sans-serif'] = ['SimHei']
|
||||
mpl.rcParams['axes.unicode_minus']=False
|
||||
|
||||
def Draw(start,end,func,lable1,lable2):
|
||||
z = np.linspace(start, end, 200)
|
||||
a = func.forward(z)
|
||||
|
@ -22,12 +26,13 @@ def Draw(start,end,func,lable1,lable2):
|
|||
p2, = plt.plot(z,da)
|
||||
plt.legend([p1,p2], [lable1, lable2])
|
||||
plt.grid()
|
||||
plt.xlabel("input : z")
|
||||
plt.ylabel("output : a")
|
||||
plt.xlabel("输入 : $z$")
|
||||
plt.ylabel("输出 : $a$")
|
||||
plt.title(lable1)
|
||||
plt.show()
|
||||
|
||||
if __name__ == '__main__':
|
||||
Draw(-7,7,CSigmoid(),"Sigmoid Function","Derivative of Sigmoid")
|
||||
Draw(-7,7,CSigmoid(),"Logistic Function","Derivative of Logistic")
|
||||
Draw(-5,5,CStep(0.3),"Step Function","Derivative of Step")
|
||||
Draw(-7,7,CSigmoid(),"Sigmoid 函数","导数")
|
||||
Draw(-7,7,CSigmoid(),"Logistic 函数","导数")
|
||||
Draw(-7,7,CTanh(),"Tanh 函数","导数")
|
||||
Draw(-5,5,CStep(0.3),"Step 函数","导数")
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
import numpy as np
|
||||
import matplotlib.pyplot as plt
|
||||
import matplotlib as mpl
|
||||
|
||||
from Activators.Relu import *
|
||||
from Activators.Elu import *
|
||||
|
@ -13,6 +14,9 @@ from Activators.Step import *
|
|||
from Activators.Tanh import *
|
||||
from Activators.BenIdentity import *
|
||||
|
||||
mpl.rcParams['font.sans-serif'] = ['SimHei']
|
||||
mpl.rcParams['axes.unicode_minus']=False
|
||||
|
||||
def Draw(start,end,func,lable1,lable2):
|
||||
z = np.linspace(start, end, 200)
|
||||
a = func.forward(z)
|
||||
|
@ -22,14 +26,14 @@ def Draw(start,end,func,lable1,lable2):
|
|||
p2, = plt.plot(z,da)
|
||||
plt.legend([p1,p2], [lable1, lable2])
|
||||
plt.grid()
|
||||
plt.xlabel("input : z")
|
||||
plt.ylabel("output : a")
|
||||
plt.xlabel("输入 : $z$")
|
||||
plt.ylabel("输出 : $a$")
|
||||
plt.title(lable1)
|
||||
plt.show()
|
||||
|
||||
if __name__ == '__main__':
|
||||
Draw(-5,5,CRelu(),"Relu Function","Derivative of Relu")
|
||||
Draw(-5,5,CRelu(),"Relu 函数","导数")
|
||||
Draw(-4,4,CElu(0.8),"ELU Function","Derivative of ELU")
|
||||
Draw(-5,5,CLeakyRelu(0.01),"Leaky Relu Function","Derivative of Leaky Relu")
|
||||
Draw(-5,5,CLeakyRelu(0.01),"Leaky Relu 函数","导数")
|
||||
Draw(-5,5,CSoftplus(),"Softplus Function","Derivative of Softplus")
|
||||
Draw(-7,7,CBenIdentity(),"BenIdentity Function","Derivative of BenIdentity")
|
||||
|
|
|
@ -27,9 +27,9 @@ class NeuralNet_2_0(object):
|
|||
print(self.subfolder)
|
||||
|
||||
self.wb1 = WeightsBias_1_0(self.hp.num_input, self.hp.num_hidden, self.hp.init_method, self.hp.eta)
|
||||
self.wb1.InitializeWeights(self.subfolder, False)
|
||||
self.wb1.InitializeWeights(self.subfolder, True)
|
||||
self.wb2 = WeightsBias_1_0(self.hp.num_hidden, self.hp.num_output, self.hp.init_method, self.hp.eta)
|
||||
self.wb2.InitializeWeights(self.subfolder, False)
|
||||
self.wb2.InitializeWeights(self.subfolder, True)
|
||||
|
||||
def __create_subfolder(self):
|
||||
if self.model_name != None:
|
||||
|
|
|
@ -4,6 +4,10 @@
|
|||
import numpy as np
|
||||
import matplotlib.pyplot as plt
|
||||
import pickle
|
||||
import matplotlib as mpl
|
||||
|
||||
mpl.rcParams['font.sans-serif'] = ['SimHei']
|
||||
mpl.rcParams['axes.unicode_minus']=False
|
||||
|
||||
# 帮助类,用于记录损失函数值极其对应的权重/迭代次数
|
||||
class TrainingHistory_2_0(object):
|
||||
|
@ -37,9 +41,9 @@ class TrainingHistory_2_0(object):
|
|||
p2, = axes.plot(self.epoch_seq, self.loss_train)
|
||||
p1, = axes.plot(self.epoch_seq, self.loss_val)
|
||||
axes.legend([p1,p2], ["validation","train"])
|
||||
axes.set_title("Loss")
|
||||
axes.set_ylabel("loss")
|
||||
axes.set_xlabel("epoch")
|
||||
axes.set_title("验证集损失函数曲线")
|
||||
axes.set_ylabel("损失函数值")
|
||||
axes.set_xlabel("迭代次数")
|
||||
if xmin != None or xmax != None or ymin != None or ymax != None:
|
||||
axes.axis([xmin, xmax, ymin, ymax])
|
||||
|
||||
|
@ -49,9 +53,9 @@ class TrainingHistory_2_0(object):
|
|||
p2, = axes.plot(self.epoch_seq, self.accuracy_train)
|
||||
p1, = axes.plot(self.epoch_seq, self.accuracy_val)
|
||||
axes.legend([p1,p2], ["validation","train"])
|
||||
axes.set_title("Accuracy")
|
||||
axes.set_ylabel("accuracy")
|
||||
axes.set_xlabel("epoch")
|
||||
axes.set_title("验证集准确率曲线")
|
||||
axes.set_ylabel("准确率")
|
||||
axes.set_xlabel("迭代次数")
|
||||
|
||||
title = params.toString()
|
||||
plt.suptitle(title)
|
||||
|
|
|
@ -10,6 +10,11 @@ what's new:
|
|||
import numpy as np
|
||||
import matplotlib.pyplot as plt
|
||||
import pickle
|
||||
import matplotlib as mpl
|
||||
|
||||
mpl.rcParams['font.sans-serif'] = ['SimHei']
|
||||
mpl.rcParams['axes.unicode_minus']=False
|
||||
|
||||
|
||||
# 帮助类,用于记录损失函数值极其对应的权重/迭代次数
|
||||
class TrainingHistory_2_2(object):
|
||||
|
@ -43,9 +48,9 @@ class TrainingHistory_2_2(object):
|
|||
p2, = axes.plot(self.epoch_seq, self.loss_train)
|
||||
p1, = axes.plot(self.epoch_seq, self.loss_val)
|
||||
axes.legend([p1,p2], ["validation","train"])
|
||||
axes.set_title("Loss")
|
||||
axes.set_ylabel("loss")
|
||||
axes.set_xlabel("epoch")
|
||||
axes.set_title("验证集损失函数值曲线")
|
||||
axes.set_ylabel("损失函数值")
|
||||
axes.set_xlabel("迭代次数")
|
||||
if xmin != None or xmax != None or ymin != None or ymax != None:
|
||||
axes.axis([xmin, xmax, ymin, ymax])
|
||||
|
||||
|
@ -55,9 +60,9 @@ class TrainingHistory_2_2(object):
|
|||
p2, = axes.plot(self.epoch_seq, self.accuracy_train)
|
||||
p1, = axes.plot(self.epoch_seq, self.accuracy_val)
|
||||
axes.legend([p1,p2], ["validation","train"])
|
||||
axes.set_title("Accuracy")
|
||||
axes.set_ylabel("accuracy")
|
||||
axes.set_xlabel("epoch")
|
||||
axes.set_title("验证集准确度值曲线")
|
||||
axes.set_ylabel("准确度值")
|
||||
axes.set_xlabel("迭代次数")
|
||||
|
||||
title = params.toString()
|
||||
plt.suptitle(title)
|
||||
|
|
|
@ -41,8 +41,9 @@ def DrawThreeCategoryPoints(X1, X2, Y_onehot, xlabel="x1", ylabel="x2", title=No
|
|||
else:
|
||||
plt.scatter(X1[i], X2[i], color=colors[j], marker=shapes[j], zorder=10)
|
||||
#end for
|
||||
plt.xlabel(xlabel)
|
||||
plt.ylabel(ylabel)
|
||||
|
||||
plt.xlabel("$" + xlabel + "$")
|
||||
plt.ylabel("$" + ylabel + "$")
|
||||
if title is not None:
|
||||
plt.title(title)
|
||||
if show:
|
||||
|
|
|
@ -3,6 +3,10 @@
|
|||
|
||||
import numpy as np
|
||||
import matplotlib.pyplot as plt
|
||||
import matplotlib as mpl
|
||||
|
||||
mpl.rcParams['font.sans-serif'] = ['SimHei']
|
||||
mpl.rcParams['axes.unicode_minus']=False
|
||||
|
||||
from HelperClass2.NeuralNet_2_2 import *
|
||||
from HelperClass2.Visualizer_1_1 import *
|
||||
|
@ -16,7 +20,7 @@ if __name__ == '__main__':
|
|||
dataReader.NormalizeY(NetType.MultipleClassifier, base=1)
|
||||
|
||||
fig = plt.figure(figsize=(6,6))
|
||||
DrawThreeCategoryPoints(dataReader.XTrainRaw[:,0], dataReader.XTrainRaw[:,1], dataReader.YTrain, "Source Data")
|
||||
DrawThreeCategoryPoints(dataReader.XTrainRaw[:,0], dataReader.XTrainRaw[:,1], dataReader.YTrain, title="源数据")
|
||||
plt.show()
|
||||
|
||||
dataReader.NormalizeX()
|
||||
|
|
Загрузка…
Ссылка в новой задаче