0% found this document useful (0 votes)
670 views

Tensorflow Presentation

This document provides an introduction to TensorFlow. It explains that TensorFlow is a machine learning framework for numerical computation using data flow graphs. It demonstrates simple linear regression examples in TensorFlow to fit a line to some sample data. It also introduces the concept of tensors, which are n-dimensional arrays that represent inputs and outputs of the data flow graphs in TensorFlow. The document provides examples of different tensor operations in TensorFlow like matrix multiplication and addition. It also discusses nonlinearities and matrix multiplication that are common components of neural networks built with TensorFlow. In the end, it provides some advice around learning gradient optimization techniques and exploring different built-in optimizers for efficiency.

Uploaded by

hail2pigdum
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
670 views

Tensorflow Presentation

This document provides an introduction to TensorFlow. It explains that TensorFlow is a machine learning framework for numerical computation using data flow graphs. It demonstrates simple linear regression examples in TensorFlow to fit a line to some sample data. It also introduces the concept of tensors, which are n-dimensional arrays that represent inputs and outputs of the data flow graphs in TensorFlow. The document provides examples of different tensor operations in TensorFlow like matrix multiplication and addition. It also discusses nonlinearities and matrix multiplication that are common components of neural networks built with TensorFlow. In the end, it provides some advice around learning gradient optimization techniques and exploring different built-in optimizers for efficiency.

Uploaded by

hail2pigdum
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 13

An Introduction into

TensorFlow
By: Jared Ostmeyer
Laboratory of Dr. Lindsay Cowell, UTSW
https://github.com/jostmey/NakedTensor

What is TensorFlow ?

y = mx + b
e
p
slo

y-intercept

0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24

import tensorflow as tf
xs = [ 0.00, 1.00, 2.00,
ys = [-0.82, -0.94, -0.12,

3.00, 4.00, 5.00, 6.00, 7.00]


0.26, 0.39, 0.64, 1.02, 1.00]

m_initial = -0.5
b_initial = 1.0
m = tf.Variable(m_initial)
b = tf.Variable(b_initial)
error = 0.0
for i in range(len(xs)):
y_model = m*xs[i]+b
error += (ys[i]-y_model)**2
operation = tf.train.GradientDescentOptimizer(learning_rate=0.001).minimize(error)
with tf.Session() as session:
session.run(tf.initialize_all_variables())
for iteration in range(10000):
session.run(operation)
print('Slope:', m.eval(), 'Intercept:', b.eval())

$ python3 serial.py
Slope: 0.297022 Intercept: -0.860827
$ # Runtime was 11.1 seconds

Math Functions
tf.exp
tf.tan

tf.pow
tf.sign

Control Flow
tf.cond
tf.do_while

Tensor Operations
tf.matmul
tf.add
tf.reduce_sum tf.cumprod

But wait, what are Tensors?


[ 0.3, 0.2, 0.4, 0.5, 0.9 ]
[
[ 0.3, 0.2, 0.4, 0.5, 0.9 ],
[ 0.6, 0.0, 0.8, 0.5, 0.4 ],
[ 0.2, 0.8, 0.8, 0.1, 0.3 ]
]

0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22

import tensorflow as tf
xs = [ 0.00, 1.00, 2.00,
ys = [-0.82, -0.94, -0.12,

3.00, 4.00, 5.00, 6.00, 7.00]


0.26, 0.39, 0.64, 1.02, 1.00]

m_initial = -0.5
b_initial = 1.0
m = tf.Variable(m_initial)
b = tf.Variable(b_initial)
ys_model = m*xs+b
error = tf.reduce_sum((ys-ys_model)**2)
operation = tf.train.GradientDescentOptimizer(learning_rate=0.001).minimize(error)
with tf.Session() as session:
session.run(tf.initialize_all_variables())
for iteration in range(10000):
session.run(operation)
print('Slope:', m.eval(), 'Intercept:', b.eval())

$ python3 tensor.py
Slope: 0.297022 Intercept: -0.860827
$ # Runtime was 2.5 seconds

[ 0.3, 0.2, 0.4, , 0.6 ]


[ 0.1, 0.2, 0.1, , 0.2 ]
[ 0.9, 0.7, 0.7, , 0.0 ]
[ 0.6, 0.5, 0.5, , 0.4 ]
[ 0.3, 0.4, 0.3, , 0.2 ]
[ 0.8, 0.9, 1.0, , 0.1 ]
[ 0.2, 0.2, 0.7, , 0.3 ]
[ 0.6, 0.4, 0.1, , 0.4 ]
[ 0.9, 0.3, 0.1, , 0.2 ]
[ 0.3, 0.2, 0.3, , 0.1 ]

S am e
M od el
S am e
M od el
S am e
M od el
S am e
M od el
S am e
M od el
S am e
M od el
S am e
M od el
S am e
M od el
S am e
M od el
S am e

A irp lan e
C at
C ar
C at
D eer
D og
D eer
M on key
S h ip
Tru ck

Nonlinearity

Matrix
Mul.

Nonlinearity

Matrix
Mul.

Nonlinearity

Advice
Learn about gradient optimization
For most models, gradient optimization is
inefficient
Explore different built-in optimizers

You might also like