Avançar para o conteúdo principal

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:

Comentários

Mensagens populares deste blogue

Let's make a car in Unity 3D

In this post we will make a simple car in Unity 3D. The Unity 3D physics engine is used in order to give the car a real behavior. This are the steps: [1] - Create a new Project

PacMan 3D

In this post we will be making a simple and classic game, the Pacman, with Unity 3D. Let's create a new a new project

Upgrading Windows 10 Home to Pro

 So I have been thinking about upgrading my Windows 10 Home Edition to the Pro version, but I always get to the point where it seems that I had to reinstall the entire SO and quit. After some investigating I have done it this way: - following this post  on the microsoft site I use one of the default keys for Windows 10 Pro and went to Settings > Update & Security > Activation > Change the product key; - next, Windows will activate the Pro functionalities and asks to restart; - now you have the Pro version but it's not activated, so you have to buy a Windows Pro Key. I went to UR cdkeys  and bought a key for less then €20; - and with the new key went to Change the product key and activated; - and it's done. Disclaimer : I have nothing to do with UR cdkeys so you can use any site to buy you cd key and your experience may vary from mine.