logistics_regression.py 文件源码

python
阅读 19 收藏 0 点赞 0 评论 0

项目:mlAlgorithms 作者: gu-yan 项目源码 文件源码
def gradient(train,
        labels,
        coef,
        bias,
        learn_rate,
        nepoch):
    for epoch in range(nepoch):
        sum_error = 0.0
        for index in range(len(train)):
            pred = predict(train[index], coef, bias)
            sum_error += (labels[index] - pred)
            bias = (bias + learn_rate * sum_error * pred * (1 - pred))
            for i in range(len(coef)):
                coef[i] = (coef[i] + learn_rate * sum_error * pred * (1 - pred) * train[index][i])
    return coef, bias

#generate standard normal distribution
#TODO the function random.gauss() can not generate stable distribution which causes diffusion gradient
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号