a = tf.zeros([3,3])
a[:,0:2] = 1
TypeError: ‘Tensor’ object does not support item assignment in TensorFlow
The reason for the error is that tensor can not be assigned directly. The solution is as follows
1. The variable tensor can be changed to:
a = tf.Variable(tf.zeros([3,3]))
a[:,0:2].assign(1)
2. Use numpy to process
b_list = []
b_list.append(a[:,0:2])
a = tf.stack(b_list)
undertake MATLAB, Python and C + + programming, machine learning, computer vision theory implementation and guidance, undergraduate and master can, salted fish trading, professional answer please go to know, for details, please contact QQ number 757160542, if you are the one
This article shares in the blog “Yu Xiaoyong” (CSDN).
Similar Posts:
- LaTeX Error: There‘s no line here to end
- TypeError: ‘tuple‘ object is not callable
- tensorflow-1.3.0rc2-cp36-cp36m-manylinux1_x86_64.whl is not a supported wheel on this platform.
- SyntaxError: invalid character in identifier
- TypeError: a bytes-like object is required, not ‘str‘
- AttributeError: ‘list‘ object has no attribute ‘astype‘
- ResourceExhaustedError (see above for traceback): OOM when allocating tensor with shape[1105,7,7
- IsADirectoryError: [Errno 21] Is a directory: ‘/home/user8/Desktop/low_light/Learning-Texture-Invari
- AttributeError: ‘NoneType‘ object has no attribute ‘append‘
- ValueError: not enough values to unpack (expected 3, got 2)