Reputation: 1418
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)
Upvotes: 3
Views: 7247
Reputation: 39
W=tf.Variable(tf.zeros([784,10]))
b=tf.Variable(tf.zeros([10]))
Upvotes: 2
Reputation: 3198
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.
Upvotes: 5