Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

这是有图片的.md #120

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions MachineLearningMathBasic/2.8 Moore-Penrose伪逆-李涛.md
Original file line number Diff line number Diff line change
@@ -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

Expand Down
45 changes: 45 additions & 0 deletions MachineLearningMathBasic/6.3 凸集与凸集分离定律-李涛.md
Original file line number Diff line number Diff line change
@@ -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())
```