There are some errors using tensorflow.Varaible:
import tensorflow as tf
sess = tf.InteractiveSession()
x = tf.placeholder(tf.float32,[None, 784])
W = tf.Variable(tf.zeros[784,10])
b = tf.Variable(tf.zeros[10])
but it shows error:
TypeError:Traceback (most recent call last)
<ipython-input-8-3086abe5ee8f> in <module>()
----> 1 W = tf.Variable(tf.zeros[784,10])
2 b = tf.Variable(tf.zeros[10])
TypeError: 'function' object is not subscriptable
I don't know where is wrong, can someone help me?(The version of tensorflow is 0.12.0)
This is what Python3 tells you when you try to subscript something that doesn't have the appropriate methods defined for subscripting.
Try to subscript an int:
1[1]
TypeError: 'int' object is not subscriptable
Try to subscript a function:
(lambda: 1)[1]
TypeError: 'function' object is not subscriptable
But getting a value from a list should work
[1,2,3][1]
2
So, it looks like zeros is a function, which can be called using parens but not subscripted into using brackets.
W=tf.Variable(tf.zeros([784,10]))
b=tf.Variable(tf.zeros([10]))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With