diff --git a/Python高级编程/函数可变参数.py b/Python高级编程/函数可变参数.py new file mode 100644 index 0000000..4a6a08d --- /dev/null +++ b/Python高级编程/函数可变参数.py @@ -0,0 +1,11 @@ +def change(age,*som): + print(age) + for i in som: + print(i) + return + +change(12,'name','year','mon','address') + +change('a1','b1') + +change('a2','b2',11) \ No newline at end of file diff --git a/ppt/第一部分 1 Python基础 1.1 1.2 1.3 1.4 .pdf b/ppt/第一部分 1 Python基础 1.1 1.2 1.3 1.4 .pdf new file mode 100644 index 0000000..857eea7 Binary files /dev/null and b/ppt/第一部分 1 Python基础 1.1 1.2 1.3 1.4 .pdf differ diff --git a/ppt/第一部分 1 Python基础 1.5 函数.pdf b/ppt/第一部分 1 Python基础 1.5 函数.pdf new file mode 100644 index 0000000..d6eda99 Binary files /dev/null and b/ppt/第一部分 1 Python基础 1.5 函数.pdf differ diff --git a/ppt/第一部分 1 Python基础 1.7 字符串.pdf b/ppt/第一部分 1 Python基础 1.7 字符串.pdf new file mode 100644 index 0000000..adc8226 Binary files /dev/null and b/ppt/第一部分 1 Python基础 1.7 字符串.pdf differ diff --git a/ppt/第一部分 1 Python基础 1.8 列表与元组.pdf b/ppt/第一部分 1 Python基础 1.8 列表与元组.pdf new file mode 100644 index 0000000..f9069d3 Binary files /dev/null and b/ppt/第一部分 1 Python基础 1.8 列表与元组.pdf differ diff --git a/ppt/第一部分 1 Python基础 1.9 集合与字典.pdf b/ppt/第一部分 1 Python基础 1.9 集合与字典.pdf new file mode 100644 index 0000000..7fe60b9 Binary files /dev/null and b/ppt/第一部分 1 Python基础 1.9 集合与字典.pdf differ diff --git a/ppt/第一部分 1 Python基础 高级特性.pdf b/ppt/第一部分 1 Python基础 高级特性.pdf new file mode 100644 index 0000000..12afbaf Binary files /dev/null and b/ppt/第一部分 1 Python基础 高级特性.pdf differ diff --git a/ppt/第一部分 2 Python面向对象 2.1.pdf b/ppt/第一部分 2 Python面向对象 2.1.pdf new file mode 100644 index 0000000..7ec3830 Binary files /dev/null and b/ppt/第一部分 2 Python面向对象 2.1.pdf differ diff --git a/ppt/第一部分 2 Python面向对象 2.2.pdf b/ppt/第一部分 2 Python面向对象 2.2.pdf new file mode 100644 index 0000000..8002efc Binary files /dev/null and b/ppt/第一部分 2 Python面向对象 2.2.pdf differ diff --git a/ppt/第一部分 3 Python 高级编程.pdf b/ppt/第一部分 3 Python 高级编程.pdf new file mode 100644 index 0000000..b338a96 Binary files /dev/null and b/ppt/第一部分 3 Python 高级编程.pdf differ diff --git a/ppt/第三部分 神经网络 卷积神经网络.pdf b/ppt/第三部分 神经网络 卷积神经网络.pdf new file mode 100644 index 0000000..bcde855 Binary files /dev/null and b/ppt/第三部分 神经网络 卷积神经网络.pdf differ diff --git a/ppt/第三部分 神经网络 概述.pdf b/ppt/第三部分 神经网络 概述.pdf new file mode 100644 index 0000000..1f70adc Binary files /dev/null and b/ppt/第三部分 神经网络 概述.pdf differ diff --git a/ppt/第二部分 机器学习 概述.pdf b/ppt/第二部分 机器学习 概述.pdf new file mode 100644 index 0000000..b8b100c Binary files /dev/null and b/ppt/第二部分 机器学习 概述.pdf differ diff --git a/ppt/第二部分 机器学习 算法.pdf b/ppt/第二部分 机器学习 算法.pdf new file mode 100644 index 0000000..0737da9 Binary files /dev/null and b/ppt/第二部分 机器学习 算法.pdf differ diff --git a/优化算法/AA.py b/优化算法/AA.py new file mode 100644 index 0000000..da93055 --- /dev/null +++ b/优化算法/AA.py @@ -0,0 +1,77 @@ +#coding:utf-8 +# https://mp.weixin.qq.com/s/ac-CgZj-avmPBraVvQUuBQ +from __future__ import print_function +import numpy as np +import matplotlib.pyplot as plt +class Function(): + def __init__(self): + self.points_x = np.linspace(-20, 20, 1000) + self.points_y = self.f(self.points_x) + + def f(self,x): + return (0.15*x)**2 + np.cos(x) + np.sin(3*x)/3 + np.cos(5*x)/5 + np.sin(7*x)/7 + + def df(self,x): + return (9/200)*x - np.sin(x) -np.sin(5*x) + np.cos(3*x) + np.cos(7*x) + + + def ddf(self,x): + return (9/200) - np.cos(x) -3*np.sin(x) - 5*np.cos(5*x) -7* np.sin(7*x) + + + + +# # +# # +# # # AdaGrad +# # for i in range(15): +# # # 绘制原来的函数 +# # plt.plot(points_x, points_y, c="b", alpha=0.5, linestyle="-") +# # # 算法开始 +# # lr = pow(1.5,-i)*32 +# # delta = 1e-7 +# # x = -20 +# # r = 0 +# # AdaGrad_x, AdaGrad_y = [], [] +# # for it in range(1000): +# # AdaGrad_x.append(x), AdaGrad_y.append(f(x)) +# # g = df(x) +# # r = r + g*g # 积累平方梯度 +# # x = x - lr /(delta + np.sqrt(r)) * g +# # +# # plt.xlim(-20, 20) +# # plt.ylim(-2, 10) +# # plt.plot(AdaGrad_x, AdaGrad_y, c="r", linestyle="-") +# # plt.scatter(AdaGrad_x[-1],AdaGrad_y[-1],90,marker = "x",color="g") +# # plt.title("AdaGrad,lr=%f"%(lr)) +# # plt.savefig("AdaGrad,lr=%f"%(lr) + ".png") +# # plt.clf() +# # +# # +# # # RMSProp +# # for i in range(15): +# # # 绘制原来的函数 +# # plt.plot(points_x, points_y, c="b", alpha=0.5, linestyle="-") +# # # 算法开始 +# # lr = pow(1.5,-i)*32 +# # delta = 1e-6 +# # rou = 0.8 +# # x = -20 +# # r = 0 +# # RMSProp_x, RMSProp_y = [], [] +# # for it in range(1000): +# # RMSProp_x.append(x), RMSProp_y.append(f(x)) +# # g = df(x) +# # r = rou * r + (1-rou)*g*g # 积累平方梯度 +# # x = x - lr /(delta + np.sqrt(r)) * g +# # +# # plt.xlim(-20, 20) +# # plt.ylim(-2, 10) +# # plt.plot(RMSProp_x, RMSProp_y, c="r", linestyle="-") +# # plt.scatter(RMSProp_x[-1],RMSProp_y[-1],90,marker = "x",color="g") +# # plt.title("RMSProp,lr=%f,rou=%f"%(lr,rou)) +# # plt.savefig("RMSProp,lr=%f,rou=%f"%(lr,rou) + ".png") +# # plt.clf() +# # + +# # diff --git a/实例学习Numpy与Matplotlib/Numpy合并.py b/实例学习Numpy与Matplotlib/Numpy合并.py index 61338d5..61694dc 100644 --- a/实例学习Numpy与Matplotlib/Numpy合并.py +++ b/实例学习Numpy与Matplotlib/Numpy合并.py @@ -12,6 +12,9 @@ print(b1.shape,b2.shape,b3.shape) b4 = np.concatenate([b2, b3]) print(f"b4 = {b4} \n ") +b5 = np.vstack([b2, b3]) +print(f"b5 = {b5} \n ") + diff --git a/梯度下降/最简单函数求极值.py b/梯度下降/最简单函数求极值.py index 47d253d..c1d296e 100644 --- a/梯度下降/最简单函数求极值.py +++ b/梯度下降/最简单函数求极值.py @@ -14,17 +14,15 @@ def plotf(loss): plt.ylabel('Loss') plt.show() - - def main(): x = 15 lr = 0.1 steps = 40 loss = [] for i in range(steps): - loss.append(f(x)) - print(loss[i]) x = x-lr*df(x) + loss.append(f(x)) + print(loss[i]) # y = f(x) # print(y) plotf(loss) diff --git a/梯度下降/最简单函数求极值tensor.py b/梯度下降/最简单函数求极值tensor.py index bdded4b..d94880d 100644 --- a/梯度下降/最简单函数求极值tensor.py +++ b/梯度下降/最简单函数求极值tensor.py @@ -27,7 +27,7 @@ def main(): f(x).backward() optimizer.step() loss.append(f(x)) - print(loss[i]) + print(f(x)) y = f(x) print("函数最小值是: ",y) plotf(loss)