Velvet Star Monitor

Standout celebrity highlights with iconic style.

updates

module 'tensorflow' has no attribute 'variable' in google Colaboratory

Writer Emily Wong

I'm trying to create a variable tensor in google Collaboratory with this code, but error because TensorFlow doesn't have a module about variables. what's the solution?

import tensorflow as tf
var_1 = tf.variable(tf.ones([2,3]))

Error:

AttributeError Traceback (most recent call last) <ipython-input-2-2666f49bf801> in <module>() ----> 1 var_1 = tf.variable(tf.ones([2,3]))
AttributeError: module 'tensorflow' has no attribute 'variable'
2

1 Answer

There is a typo error. Use capital letter V for Variable.

You can refer below code for the same.

import tensorflow as tf
var_1 = tf.Variable(tf.ones([2,3]))
var_1

Click here, for more details

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy