tf.Variable()是变量
tf.constant()是常量
但是书上用tf.Variable(tf.constant(0.1, shape=[OUTPUT_NODE]))来表示偏置项,为什么这么表示
为什么不直接用tf.Variable(0.1, shape=[OUTPUT_NODE])来表示
tensorflow中tf.Variable(tf.constant)变量吗?为什么可以这么写?
- 写回答
- 好问题 0 提建议
- 关注问题
- 邀请回答
-
2条回答 默认 最新
八云黧 2021-08-08 22:58关注看源码:
def __init__(self, initial_value=None, trainable=None, validate_shape=True, caching_device=None, name=None, variable_def=None, dtype=None, import_scope=None, constraint=None, synchronization=VariableSynchronization.AUTO, aggregation=VariableAggregation.NONE, shape=None): """Creates a new variable with value `initial_value`. Args: initial_value: A `Tensor`, or Python object convertible to a `Tensor`, which is the initial value for the Variable. The initial value must have a shape specified unless `validate_shape` is set to False. Can also be a callable with no argument that returns the initial value when called. In that case, `dtype` must be specified. (Note that initializer functions from init_ops.py must first be bound to a shape before being used here.) """Variable的构造函数第一个参数说了是一个Tensor对象,不能是值
解决 无用评论 打赏 举报