python-tensorflowHow do I create a "Hello World" program using Python and TensorFlow?
This "Hello World" program using Python and TensorFlow will print "Hello World" to the console.
import tensorflow as tf
hello = tf.constant('Hello, World!')
sess = tf.Session()
print(sess.run(hello))
Output example
b'Hello, World!'
The code consists of the following parts:
- Import TensorFlow as
tf
: This is done usingimport tensorflow as tf
. - Create a constant string
hello
with valueHello, World!
: This is done usinghello = tf.constant('Hello, World!')
. - Create a session
sess
: This is done usingsess = tf.Session()
. - Print
hello
to the console: This is done usingprint(sess.run(hello))
.
Helpful links
More of Python Tensorflow
- How can I use Python and TensorFlow to create an XOR gate?
- How can I check the compatibility of different versions of Python and TensorFlow?
- How can I use TensorFlow Lite with XNNPACK in Python?
- How do I uninstall Python TensorFlow?
- How do I resolve a SymbolAlreadyExposedError when the symbol "zeros" is already exposed as () in TensorFlow Python util tf_export?
- How can I use Python and TensorFlow to handle illegal hardware instructions in Zsh?
- How can I use YOLOv3 with Python and TensorFlow?
- How do I check the version of Python Tensorflow I'm using?
- How do I check which version of TensorFlow I am using with Python?
- ¿Cómo implementar reconocimiento facial con TensorFlow y Python?
See more codes...