segunda-feira, 12 de fevereiro de 2018

Introduction to TensorFlow - Part 1

"TensorFlow is an open source software library for numerical computation" in tensorflow.org

In TensorFlow each node can be a constant, a variable or a numerical expression that uses variables and/or constants.

This nodes can be executed in a CPU or a GPU taking advantage of multicore devices.

Start by import the tensorflow library:

import tensorflow as tf

Create a constant with:

node1 = tf.constant(3.0)

or

node2 = tf.constant(4.0, dtype=tf.float32)

The first line allows tensorflow to guess the data type.

Start a tensorflow session:

sess = tf.Session()

If you need to see the node type use:

print(node1,node2)

With this line you get to evaluate the nodes value:

print(sess.run([node1,node2]))

Create a mathematical function that adds the two constants with:

sumnodes = tf.add(node1,node2)

Evaluate the function:

print(sess.run(sumnodes))

Youtube video:


Code on GiHub

How to install TensorFlow in Anaconda:

Sem comentários:

Enviar um comentário