How can I change the shape of a variable in TensorFlow?

前端 未结 6 556
醉梦人生
醉梦人生 2020-12-03 07:21

TensorFlow tutorial says that at creation time we need to specify the shape of tensors. That shape automatically becomes the shape of the tensor. It also says that TensorF

6条回答
  •  误落风尘
    2020-12-03 07:38

    tf.Variable: Use the shape argument with None

    A feature was added in 1.14 that allows to specify unknown shapes.

    If shape is None, the initial shape value is used.

    If shape is specified, this is used as the shape and allows to have None.

    Example:

    var = tf.Variable(array, shape=(None, 10))
    

    This allows to later on assign values with shapes matching the shape above (e.g. arbitrary shapes in axis 0)

    var.assign(new_value)

提交回复
热议问题