lr*param.grad/batch_size 结果最终为一个标量(具体数值)
param是一个列表
param[:]=param-lr*param.grad/batch_size会把列表中的所有元素分别运算:
param-lr*param.grad/batch_size
import numpy as np
w=np.random.normal(scale=0.01,size=(10,1))
print(w.T)
b=np.zeros(shape=(1,))
print(b)
print('*'*10)
params=[w,b]
lr=1
for param in params:print(param.T)param[:]=param-lr*2print(param)
运行结果: