为什么在下面的for循环中需要下划线_
。我尝试打印_
,它的作用就像常规变量一样。它有什么特殊用途吗?
为什么*
中需要星号plt.plot(*zip(*guesses),marker='.')
,所以我很难理解这一行代码。请帮忙。谢谢!
y_guess = tf.Variable(np.zeros(2,dtype='float32'))
y_true = tf.range(1,3,dtype='float32')
loss = tf.reduce_mean((y_guess - y_true + tf.random_normal([2]))**2)
optimizer = tf.train.MomentumOptimizer(0.01,0.9).minimize(loss,var_list=y_guess)
from IPython.display import clear_output
s.run(tf.global_variables_initializer())
guesses = [s.run(y_guess)]
for _ in range(100):
# print(_)
s.run(optimizer)
guesses.append(s.run(y_guess))
clear_output(True)
plt.plot(*zip(*guesses),marker='.')
plt.scatter(*s.run(y_true),c='red')
plt.show()