python-tensorflowHow do I resolve a SymbolAlreadyExposedError when the symbol "zeros" is already exposed as () in TensorFlow Python util tf_export?
The SymbolAlreadyExposedError
is a common error when using TensorFlow Python util tf_export
and occurs when the symbol "zeros" is already exposed as () in TensorFlow Python util tf_export
.
To resolve this error, you can use the tf.get_variable
function to get the variable and use the tf.zeros
function to initialize the variable.
For example:
import tensorflow as tf
x = tf.get_variable('x', shape=[2,2], initializer=tf.zeros)
with tf.Session() as sess:
sess.run(tf.global_variables_initializer())
print(sess.run(x))
# Output
[[0. 0.]
[0. 0.]]
The code above consists of the following parts:
import tensorflow as tf
- imports the TensorFlow library.x = tf.get_variable('x', shape=[2,2], initializer=tf.zeros)
- creates the variablex
and initializes it with thetf.zeros
function.with tf.Session() as sess:
- creates a TensorFlow session.sess.run(tf.global_variables_initializer())
- initializes all the global variables.print(sess.run(x))
- prints the variablex
.
By using the tf.get_variable
and tf.zeros
functions, the SymbolAlreadyExposedError
can be resolved.
Helpful links
More of Python Tensorflow
- ¿Cómo implementar reconocimiento facial con TensorFlow y Python?
- How can I use Python and TensorFlow to handle illegal hardware instructions in Zsh?
- How can I use Tensorflow 1.x with Python 3.8?
- How can I determine the best Python version to use for TensorFlow?
- How can I resolve a TensorFlow Graph Execution Error caused by an unimplemented error?
- How can I convert a Tensor object to a list in Python using TensorFlow?
- How can I install and use TensorFlow on a Windows machine using Python?
- How can I install TensorFlow for Python 3.7?
- How do I use TensorFlow 1.15 with Python?
See more codes...