From 312ae3ab506eecf5d7ee6a94e5a63531fa063cf6 Mon Sep 17 00:00:00 2001 From: Ament <44716454+Amentman@users.noreply.github.com> Date: Wed, 28 Aug 2019 17:58:36 +0800 Subject: [PATCH 1/4] Add files via upload --- ...2\351\200\206-\346\235\216\346\266\233.md" | 23 ++++++++++ ...2\345\276\213-\346\235\216\346\266\233.md" | 45 +++++++++++++++++++ 2 files changed, 68 insertions(+) create mode 100644 "2.8 Moore-Penrose\344\274\252\351\200\206-\346\235\216\346\266\233.md" create mode 100644 "6.3 \345\207\270\351\233\206\344\270\216\345\207\270\351\233\206\345\210\206\347\246\273\345\256\232\345\276\213-\346\235\216\346\266\233.md" diff --git "a/2.8 Moore-Penrose\344\274\252\351\200\206-\346\235\216\346\266\233.md" "b/2.8 Moore-Penrose\344\274\252\351\200\206-\346\235\216\346\266\233.md" new file mode 100644 index 00000000..d386571d --- /dev/null +++ "b/2.8 Moore-Penrose\344\274\252\351\200\206-\346\235\216\346\266\233.md" @@ -0,0 +1,23 @@ +# 2.8 Moore-Penrose伪逆-李涛 + +![](https://tva1.sinaimg.cn/large/006y8mN6ly1g6fjbz5i93j318a0qiag2.jpg) +![](https://tva1.sinaimg.cn/large/006y8mN6ly1g6fjdlbpduj318m0iun0r.jpg) +```python +import scipy as SP + +a = [[1, 3], + [2, 5], + [1, 1]] + +b = [[1], + [8], + [13]] + +#x=19 y=-6 + +#c = SP.linalg.solve(a, b) + +pi_a = SP.linalg.pinv(a) + +s = pi_a.dot(b) +``` diff --git "a/6.3 \345\207\270\351\233\206\344\270\216\345\207\270\351\233\206\345\210\206\347\246\273\345\256\232\345\276\213-\346\235\216\346\266\233.md" "b/6.3 \345\207\270\351\233\206\344\270\216\345\207\270\351\233\206\345\210\206\347\246\273\345\256\232\345\276\213-\346\235\216\346\266\233.md" new file mode 100644 index 00000000..151a7866 --- /dev/null +++ "b/6.3 \345\207\270\351\233\206\344\270\216\345\207\270\351\233\206\345\210\206\347\246\273\345\256\232\345\276\213-\346\235\216\346\266\233.md" @@ -0,0 +1,45 @@ +# 6.3 凸集与凸集分离定律-李涛 +![](https://tva1.sinaimg.cn/large/006y8mN6ly1g6fjg1lhx6j30r20rk421.jpg) +![](https://tva1.sinaimg.cn/large/006y8mN6ly1g6fjg1f5udj30pe13sdje.jpg) +![](https://tva1.sinaimg.cn/large/006y8mN6ly1g6fjg19xnxj30p604o0u7.jpg) +``` +from cvxpy import * +import cvxpy as cvx + +``` +``` +problem : +minimize (x-y)^2 +subject to + x+y=1 + x-y>=1 +``` +``` +from cvxpy import * +# Create two scalar optimization variables. +# 在CVXPY中变量有标量(只有数值大小),向量,矩阵。 +# 在CVXPY中有常量(见下文的Parameter) +x = Variable() #定义变量x,定义变量y。两个都是标量 +y = Variable() +# Create two constraints. +#定义两个约束式 +constraints = [x + y == 1, + x - y >= 1] +#优化的目标函数 +obj = Minimize(square(x - y)) +#把目标函数与约束传进Problem函数中 +prob = Problem(obj, constraints) +prob.solve() # Returns the optimal value. +print("status:", prob.status) +print("optimal value", prob.value) #最优值 +print("optimal var", x.value, y.value) #x与y的解 +# Replace the objective. 不同的目标函数,相同的约束 +prob2 = cvx.Problem(cvx.Maximize(x + y), prob.constraints) +print("optimal p1 value", prob2.solve()) + +# Replace the constraint (x + y == 1).#不同的约束,相同的目标函数 +constraints = [x + y <= 3] + prob.constraints[1:] #注意:此处是列表相加,prob.constraints[1:]取prob的约束集中 +#从第二个开始的所有约束。 +prob2 = cvx.Problem(prob.objective, constraints) +print("optimal P2 value", prob2.solve()) +``` \ No newline at end of file From 3565991a6d040dc63c4517ed34deb2c6e0dc8304 Mon Sep 17 00:00:00 2001 From: Ament <44716454+Amentman@users.noreply.github.com> Date: Wed, 28 Aug 2019 18:00:12 +0800 Subject: [PATCH 2/4] =?UTF-8?q?Delete=206.3=20=E5=87=B8=E9=9B=86=E4=B8=8E?= =?UTF-8?q?=E5=87=B8=E9=9B=86=E5=88=86=E7=A6=BB=E5=AE=9A=E5=BE=8B-?= =?UTF-8?q?=E6=9D=8E=E6=B6=9B.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...2\345\276\213-\346\235\216\346\266\233.md" | 45 ------------------- 1 file changed, 45 deletions(-) delete mode 100644 "6.3 \345\207\270\351\233\206\344\270\216\345\207\270\351\233\206\345\210\206\347\246\273\345\256\232\345\276\213-\346\235\216\346\266\233.md" diff --git "a/6.3 \345\207\270\351\233\206\344\270\216\345\207\270\351\233\206\345\210\206\347\246\273\345\256\232\345\276\213-\346\235\216\346\266\233.md" "b/6.3 \345\207\270\351\233\206\344\270\216\345\207\270\351\233\206\345\210\206\347\246\273\345\256\232\345\276\213-\346\235\216\346\266\233.md" deleted file mode 100644 index 151a7866..00000000 --- "a/6.3 \345\207\270\351\233\206\344\270\216\345\207\270\351\233\206\345\210\206\347\246\273\345\256\232\345\276\213-\346\235\216\346\266\233.md" +++ /dev/null @@ -1,45 +0,0 @@ -# 6.3 凸集与凸集分离定律-李涛 -![](https://tva1.sinaimg.cn/large/006y8mN6ly1g6fjg1lhx6j30r20rk421.jpg) -![](https://tva1.sinaimg.cn/large/006y8mN6ly1g6fjg1f5udj30pe13sdje.jpg) -![](https://tva1.sinaimg.cn/large/006y8mN6ly1g6fjg19xnxj30p604o0u7.jpg) -``` -from cvxpy import * -import cvxpy as cvx - -``` -``` -problem : -minimize (x-y)^2 -subject to - x+y=1 - x-y>=1 -``` -``` -from cvxpy import * -# Create two scalar optimization variables. -# 在CVXPY中变量有标量(只有数值大小),向量,矩阵。 -# 在CVXPY中有常量(见下文的Parameter) -x = Variable() #定义变量x,定义变量y。两个都是标量 -y = Variable() -# Create two constraints. -#定义两个约束式 -constraints = [x + y == 1, - x - y >= 1] -#优化的目标函数 -obj = Minimize(square(x - y)) -#把目标函数与约束传进Problem函数中 -prob = Problem(obj, constraints) -prob.solve() # Returns the optimal value. -print("status:", prob.status) -print("optimal value", prob.value) #最优值 -print("optimal var", x.value, y.value) #x与y的解 -# Replace the objective. 不同的目标函数,相同的约束 -prob2 = cvx.Problem(cvx.Maximize(x + y), prob.constraints) -print("optimal p1 value", prob2.solve()) - -# Replace the constraint (x + y == 1).#不同的约束,相同的目标函数 -constraints = [x + y <= 3] + prob.constraints[1:] #注意:此处是列表相加,prob.constraints[1:]取prob的约束集中 -#从第二个开始的所有约束。 -prob2 = cvx.Problem(prob.objective, constraints) -print("optimal P2 value", prob2.solve()) -``` \ No newline at end of file From 92d688691533073e84d7a562468011d880bb11ee Mon Sep 17 00:00:00 2001 From: Ament <44716454+Amentman@users.noreply.github.com> Date: Wed, 28 Aug 2019 18:00:59 +0800 Subject: [PATCH 3/4] =?UTF-8?q?Delete=202.8=20Moore-Penrose=E4=BC=AA?= =?UTF-8?q?=E9=80=86-=E6=9D=8E=E6=B6=9B.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...2\351\200\206-\346\235\216\346\266\233.md" | 23 ------------------- 1 file changed, 23 deletions(-) delete mode 100644 "2.8 Moore-Penrose\344\274\252\351\200\206-\346\235\216\346\266\233.md" diff --git "a/2.8 Moore-Penrose\344\274\252\351\200\206-\346\235\216\346\266\233.md" "b/2.8 Moore-Penrose\344\274\252\351\200\206-\346\235\216\346\266\233.md" deleted file mode 100644 index d386571d..00000000 --- "a/2.8 Moore-Penrose\344\274\252\351\200\206-\346\235\216\346\266\233.md" +++ /dev/null @@ -1,23 +0,0 @@ -# 2.8 Moore-Penrose伪逆-李涛 - -![](https://tva1.sinaimg.cn/large/006y8mN6ly1g6fjbz5i93j318a0qiag2.jpg) -![](https://tva1.sinaimg.cn/large/006y8mN6ly1g6fjdlbpduj318m0iun0r.jpg) -```python -import scipy as SP - -a = [[1, 3], - [2, 5], - [1, 1]] - -b = [[1], - [8], - [13]] - -#x=19 y=-6 - -#c = SP.linalg.solve(a, b) - -pi_a = SP.linalg.pinv(a) - -s = pi_a.dot(b) -``` From b2eb2bf2dfd100795dc4ee30cb854e0b636911d1 Mon Sep 17 00:00:00 2001 From: Ament <44716454+Amentman@users.noreply.github.com> Date: Wed, 28 Aug 2019 18:01:30 +0800 Subject: [PATCH 4/4] Add files via upload --- ...2\351\200\206-\346\235\216\346\266\233.md" | 5 +-- ...2\345\276\213-\346\235\216\346\266\233.md" | 45 +++++++++++++++++++ 2 files changed, 47 insertions(+), 3 deletions(-) create mode 100644 "MachineLearningMathBasic/6.3 \345\207\270\351\233\206\344\270\216\345\207\270\351\233\206\345\210\206\347\246\273\345\256\232\345\276\213-\346\235\216\346\266\233.md" diff --git "a/MachineLearningMathBasic/2.8 Moore-Penrose\344\274\252\351\200\206-\346\235\216\346\266\233.md" "b/MachineLearningMathBasic/2.8 Moore-Penrose\344\274\252\351\200\206-\346\235\216\346\266\233.md" index 36059919..d386571d 100644 --- "a/MachineLearningMathBasic/2.8 Moore-Penrose\344\274\252\351\200\206-\346\235\216\346\266\233.md" +++ "b/MachineLearningMathBasic/2.8 Moore-Penrose\344\274\252\351\200\206-\346\235\216\346\266\233.md" @@ -1,8 +1,7 @@ # 2.8 Moore-Penrose伪逆-李涛 -![-w797](media/15669588348534/15669601763364.jpg) -![-w803](media/15669588348534/15669602014898.jpg) - +![](https://tva1.sinaimg.cn/large/006y8mN6ly1g6fjbz5i93j318a0qiag2.jpg) +![](https://tva1.sinaimg.cn/large/006y8mN6ly1g6fjdlbpduj318m0iun0r.jpg) ```python import scipy as SP diff --git "a/MachineLearningMathBasic/6.3 \345\207\270\351\233\206\344\270\216\345\207\270\351\233\206\345\210\206\347\246\273\345\256\232\345\276\213-\346\235\216\346\266\233.md" "b/MachineLearningMathBasic/6.3 \345\207\270\351\233\206\344\270\216\345\207\270\351\233\206\345\210\206\347\246\273\345\256\232\345\276\213-\346\235\216\346\266\233.md" new file mode 100644 index 00000000..151a7866 --- /dev/null +++ "b/MachineLearningMathBasic/6.3 \345\207\270\351\233\206\344\270\216\345\207\270\351\233\206\345\210\206\347\246\273\345\256\232\345\276\213-\346\235\216\346\266\233.md" @@ -0,0 +1,45 @@ +# 6.3 凸集与凸集分离定律-李涛 +![](https://tva1.sinaimg.cn/large/006y8mN6ly1g6fjg1lhx6j30r20rk421.jpg) +![](https://tva1.sinaimg.cn/large/006y8mN6ly1g6fjg1f5udj30pe13sdje.jpg) +![](https://tva1.sinaimg.cn/large/006y8mN6ly1g6fjg19xnxj30p604o0u7.jpg) +``` +from cvxpy import * +import cvxpy as cvx + +``` +``` +problem : +minimize (x-y)^2 +subject to + x+y=1 + x-y>=1 +``` +``` +from cvxpy import * +# Create two scalar optimization variables. +# 在CVXPY中变量有标量(只有数值大小),向量,矩阵。 +# 在CVXPY中有常量(见下文的Parameter) +x = Variable() #定义变量x,定义变量y。两个都是标量 +y = Variable() +# Create two constraints. +#定义两个约束式 +constraints = [x + y == 1, + x - y >= 1] +#优化的目标函数 +obj = Minimize(square(x - y)) +#把目标函数与约束传进Problem函数中 +prob = Problem(obj, constraints) +prob.solve() # Returns the optimal value. +print("status:", prob.status) +print("optimal value", prob.value) #最优值 +print("optimal var", x.value, y.value) #x与y的解 +# Replace the objective. 不同的目标函数,相同的约束 +prob2 = cvx.Problem(cvx.Maximize(x + y), prob.constraints) +print("optimal p1 value", prob2.solve()) + +# Replace the constraint (x + y == 1).#不同的约束,相同的目标函数 +constraints = [x + y <= 3] + prob.constraints[1:] #注意:此处是列表相加,prob.constraints[1:]取prob的约束集中 +#从第二个开始的所有约束。 +prob2 = cvx.Problem(prob.objective, constraints) +print("optimal P2 value", prob2.solve()) +``` \ No newline at end of file