Getting Started with TensorFlow: Build and Run Your First Computation Graph

This article introduces TensorFlow, covering its origins, architecture, programming model, and how to construct and execute a simple computation graph with code examples, while also explaining its deployment options across devices and distributed setups.

360 Zhihui Cloud Developer
360 Zhihui Cloud Developer
360 Zhihui Cloud Developer
Getting Started with TensorFlow: Build and Run Your First Computation Graph

Preface

At a recent AI summit in Wuzhen, AlphaGo 2.0 faced world champion Ke Jie in three matches, highlighting how deep learning, especially TensorFlow, has quietly entered our daily conversation.

TensorFlow Framework Overview

Google open‑sourced its internal machine‑learning framework DistBelief at the end of 2015; after releasing distributed and 1.0 versions, TensorFlow quickly amassed nearly 60 k stars on GitHub, surpassing older frameworks and becoming the most popular deep‑learning project. It is used not only in computer‑vision but also in reinforcement learning, natural‑language processing, and many other scenarios.

The backend is written in high‑performance C++/CUDA, while front‑ends include Python, C++, Go, and Java. TensorFlow runs on heterogeneous platforms such as Android, iOS, CPU servers, and GPU clusters. In addition to common deep‑learning algorithms like CNN and RNN, it implements classic machine‑learning methods such as linear regression and random forests.

TensorFlow Programming Model Overview

Building the Graph

TensorFlow represents a program as a directed computation graph where nodes are operations or variables and edges are tensors that flow between them.

Example code that defines variables, a placeholder, and an operation:

import tensorflow as tf
b = tf.Variable(tf.zeros([100]))           # 100‑dim vector of zeros
w = tf.Variable(tf.random_uniform([784,100], -1, 1)) # 784×100 matrix
x = tf.placeholder(name="x")               # input placeholder
relu = tf.nn.relu(tf.matmul(w, x) + b)     # Relu(Wx+b)
C = [...]

The resulting graph can be visualized as:

Running the Graph

After the graph is built, a Session must be created to execute it.

s = tf.Session()
for step in range(0, 10):
    input = ...construct 100‑D input array...   # create 100‑dim input vector
    result = s.run(C, feed_dict={x: input})

Implementation

TensorFlow uses a client‑master‑worker architecture. The client interacts with a Session, the master coordinates multiple workers, and each worker can be attached to various hardware devices such as x86 CPUs, ARM CPUs, GPUs, or Google’s TPU. It supports both single‑machine mode (client, master, and workers on one process) and distributed mode (components on different machines).

Diagram of the two deployment modes:

When multiple devices are present, TensorFlow assigns operations using cost‑estimation and user‑specified strategies, handling data transfer and communication automatically.

Conclusion

This article covered TensorFlow’s programming model and architectural basics; upcoming posts will share practical tips, lessons learned, and the author’s experience deploying TensorFlow on Kubernetes.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

TensorFlowDistributed TrainingComputation Graph
360 Zhihui Cloud Developer
Written by

360 Zhihui Cloud Developer

360 Zhihui Cloud is an enterprise open service platform that aims to "aggregate data value and empower an intelligent future," leveraging 360's extensive product and technology resources to deliver platform services to customers.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.