神经网络学习入门:热冷学习与梯度下降解析
1. 热冷学习
热冷学习可能是最简单的学习形式。以下是在Jupyter笔记本中执行的代码,用于尝试正确预测0.8:
weight = 0.5
input = 0.5
goal_prediction = 0.8
step_amount = 0.001
for iteration in range(1101):
prediction = input * weight
error = (prediction - goal_prediction) ** 2
print("Error:" + str(error) + " Prediction:" + str(prediction))
up_prediction = input * (weight + step_amount)
up_error = (goal_prediction - up_prediction) ** 2
down_prediction = input * (weight - step_amount)
down_error = (goal_prediction - down_prediction) ** 2
if(down_error < up_error):
weight = weight - step_amount
if(down_error > up_error):
weight = weight + step_amount
这段代码的逻辑是:
- 先进行一次预测,计
超级会员免费看
订阅专栏 解锁全文
12万+

被折叠的 条评论
为什么被折叠?



