我有一个优化器获取二维初始点,并生成一个二维的答案。下图中红点为初始点,蓝点为解决方案
我看不到解点的密度,因为我在循环中走得更远,如下所示
import matplotlib.pyplot as plt
exp = 100
for i in range(exp):
fx = convex()
#plotting initial points
plt.scatter(fx.x[0],fx.x[1], c='r',s=1)
#Finding optimal solution
while fx.fvalue() > 1e-4:
fx.new_x(l2=True, alpha = 6, sgd = True)
#plotting optimal solution
plt.scatter(fx.x[0],fx.x[1], c='b', s=1)
plt.xlabel('x')
plt.ylabel('y')
plt.legend(['Initial values', 'Solutions'])
fx
是convex
类的一个实例,该类将x
作为其属性并随机初始化,然后在while循环中更新
我希望动态地或至少在结束for
循环之后看到解决方案点的累积
目前没有回答
相关问题 更多 >
编程相关推荐