Skip to content

assign() got an unexpected keyword argument 'validate_shape' #35667

@bersbersbers

Description

@bersbersbers

System information

  • Have I written custom code (as opposed to using a stock example script provided in TensorFlow):
import tensorflow as tf

a = tf.Variable(2)
a.assign(5)
assert a.numpy() == 5

# ValueError: Shapes () and (2,) are incompatible
a.assign([1,2])  

# TypeError: assign() got an unexpected keyword argument 'validate_shape'
a.assign([1,2], validate_shape=False)

# ValueError: Shapes () and (2,) are incompatible
tf.compat.v1.assign(a, [1,2], validate_shape=False)  

  • OS Platform and Distribution (e.g., Linux Ubuntu 16.04): Windows 10, Linux
  • TensorFlow installed from (source or binary): pip
  • TensorFlow version (use command below): 2.0.0, 2.1.0
  • Python version: 3.7

Describe the current behavior

tf.assign had a validate_shape parameter that Variable.assign seems to be missing.

In addition, the docs say:

If you want to change the shape of a variable later you have to use an assign Op with validate_shape=False.

https://www.tensorflow.org/api_docs/python/tf/Variable

How should one change the shape of a variable?

Code to reproduce the issue
See above.

Metadata

Metadata

Labels

TF 2.0Issues relating to TensorFlow 2.0TF 2.1for tracking issues in 2.1 releasecomp:opsOPs related issuesstat:awaiting tensorflowerStatus - Awaiting response from tensorflowertype:docs-bugDocument issues

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions