亲爱的同学编码器和科学家伙:)在绘制matplotlib二维函数
我使用Python和numpy的和matplotlib模拟感知,自豪地说,它工作得很好。
我使用python甚至很难我从来没有见过它,因为我听说matplotlib提供了惊人的图形可视化功能。
使用函数下面我得到的2D阵列看起来像这样: [[aplha_1,900],[alpha_2],600,...,[alpha_99,900]
所以我得到这个2D阵列和我想写一个函数,使我能够分析收敛。
我在寻找的东西,可以轻松,直观地(没有时间学习5小时一个全新的库现在)得出这样的函数素描:
def get_convergence_for_alpha(self, _alpha):
epochs = []
for i in range(0, 5):
epochs.append(self.perceptron_algorithm())
self.weights = self.generate_weights()
avg = sum(epochs, 0)/len(epochs)
res = [_alpha, avg]
return res
这是整个世代的功能。
def alpha_convergence_function(self):
res = []
for i in range(1, 100):
res.append(self.get_convergence_for_alpha(i/100))
return res
这很容易做到吗?
可以简化和使用'NumPy'的矢量运算优化代码 –