简介 赋值操作,更新参数的值并返回。调用assign_sub前,先用 tf.Variable 定义变量 w 为可训练(可自更新)。 代码 import tensorflow as tf x = tf.Variable(4.7) x.assign_sub(1) print("x:", x) x = tf.Variable(tf.constant(6)) x.assign_sub(1) print(x)