Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
SlideShare a Scribd company logo
Explore	and	have	fun	with	
TensorFlow
An	introductory	to	TensorFlow
Poo	Kuan	Hoong
https://www.facebook.com/groups/TensorFlowMY/
Disclaimer: The views and opinions
expressed in this slides are those of
the author and do not necessarily
reflect the official policy or position of
ASEAN Data Analytics Exchange
(ADAX). Examples of analysis
performed within this slides are only
examples. They should not be utilized
in real-world analytic products as they
are based only on very limited and
dated open source information.
Assumptions made within the analysis
are not reflective of the position of
ADAX.
Agenda
• Deep	Learning	Libraries
• What	is	TensorFlow?
• Why	it	is	called	TensorFlow?
• Steps	to	start	TensorFlow
• TensorFlow Graph
• Variables	&	Placeholders
• Gradient
• TensorFlow Architecture
• Demo
About	me
Poo	Kuan	Hoong,	http://www.linkedin.com/in/kuanhoong
• Senior	Manager	Data	Science
• Senior	Lecturer
• Chairperson	Data	Science	
Institute
• Founder	R	User	Group	&	
TensorFlow User	Group
• Speaker/Trainer
• Senior	Data	Scientist
TensorFlow &	Deep	Learning	Malaysia	Group
The	TensorFlow &	Deep	Learning	
Malaysia	group's	aims	are:
• To	enable	people	to	create	and	deploy	
their	own	Deep	Learning	models	built	
using	primarily	TensorFlow or	other	
Deep	Learning	libraries.
• To	build	the	key	skill	sets	for	this	group	
from	the	combination	of	both	beginner	
and	intermediate	models	as	well	as	
advancing	to	the	next	level
• A	knowledge	sharing	and	presentations	
platform	in	relation	to	the	cutting	edge	
deep	learning	research	papers	and	
techniques.
https://www.facebook.com/groups/TensorFlowMY/
https://www.meetup.com/tensorflow-deep-learning-malaysia
https://www.meetup.com/MY-RUserGroup/
https://www.facebook.com/rusergroupmalaysia/
Deep	learning	libraries
What	is	TensorFlow?
• URL:	https://www.tensorflow.org/
• Released	under	the	open	source	license on	
November	9,	2015
• Current	version	1.2
• Open	source	software	library	for	
numerical	computation	using	data	flow	
graphs	
• Originally	developed	by	Google	Brain	Team	
to	conduct	machine	learning	and	deep	
neural	networks	research	
• General	enough	to	be	applicable	in	a	wide	
variety	of	other	domains	as	well	
• TensorFlow provides	an	extensive	suite	of	
functions	and	classes	that	allow	users	to	
build	various	models	from	scratch.
Most	popular	on	Github
https://github.com/tensorflow/tensorflow
TensorFlow architecture
• Core	in	C++
• Low	overhead
• Different	front	ends	for	specifying/driving	the	computation
• Python,	C++,	R	and	many	more
CPU	- GPU
• In	TensorFlow,	the	supported	
device	types	
are CPU and GPU.	They	are	
represented	as strings.	For	
example:
• "/cpu:0": The	CPU	of	your	
machine.
• "/gpu:0": The	GPU	of	
your	machine,	if	you	have	one.
• "/gpu:1": The	second	
GPU	of	your	machine,	etc.
Why	it	is	called	TensorFlow?
• What	is	a	Tensor?
Why	it	is	called	
TensorFlow?
• TensorFlow is	based	on	
computation	data	flow	graph
• TensorFlow separates	
definition	of	computations	
from	their	execution
Steps	to	start	with	TensorFlow
• Step	1:	Assemble	a	computational	graph
• Step	2:	Use	a	session	to	execute	operations	in	the	graph
TensorFlow Graph
3
5
add
TensorFlow Graph
• To	get	the	value	of	a
• Create	a	session,	assign	it	to	variable	‘sess’	so	we	can	call	it	later
• Within	the	session,	evaluate	the	graph	to	fetch	the	value	of	a
import tensorflow as tf
a = tf.add(3, 5)
sess = tf.Session()
print (sess.run(a))
sess.close()
• A	Session	object	encapsulates	the	environment	in	which	Operation	objects	are	executed,	
and	Tensor	objects	are	evaluated.	
3
5
add
8
TensorFlow Graph
Xw
MatMul
b
Add
TensorFlow performs	
operations
User	Feeds	
inputs
TensorFlow
Trains	
Variables
User	Fetches	
Outputs
TensorFlow
Flows	tensors
ReLu
Variables
• Variables to	hold	and	
update	parameters.
• Variables	are	in-memory	
buffers	containing	tensors.	
• Must	be	explicitly	
initialized	and	can	be	
saved	to	disk	during	and	
after	training
Placeholder
• A placeholder is	simply	
a	variable	that	will	be	
assigned	data	to	at	a	
later	date.	
• It	allows	operations	to	
be	created	and	
computation	graph	to	
be	built,	without	
needing	the	data.
Learn	Parameters:	Optimization
• The	Optimizer	base	class	provides	
methods	to	compute	gradients	for	a	
loss	and	apply	gradients	to	variables.	
• A	collection	of	subclasses	implement	
classic	optimization	algorithms	such	
as	GradientDescent and	Adagrad.
• TensorFlow provides	functions	to	
compute	the	derivatives	for	a	given	
TensorFlow computation	graph,	
adding	operations	to	the	graph.
Learn	parameters:	Optimization
TensorBoard
• Visualize	your	TensorFlow graph
• Plot	quantitative	metrics	about	
the	execution	of	your	graph
• Show	additional	data	like	
images	that	pass	through	it
TensorFlow Models
https://github.com/tensorflow/models
Models
• adversarial_crypto:	protecting	communications	with	adversarial	neural	cryptography.
• adversarial_text:	semi-supervised	sequence	learning	with	adversarial	training.
• attention_ocr:	a	model	for	real-world	image	text	extraction.
• autoencoder:	various	autoencoders.
• cognitive_mapping_and_planning:	implementation	of	a	spatial	memory	based	mapping	
and	planning	architecture	for	visual	navigation.
• compression:	compressing	and	decompressing	images	using	a	pre-trained	Residual	GRU	
network.
• differential_privacy:	privacy-preserving	student	models	from	multiple	teachers.
• domain_adaptation:	domain	separation	networks.
• im2txt:	image-to-text	neural	network	for	image	captioning.
• inception:	deep	convolutional	networks	for	computer	vision.
TensorFlow Serving
• Flexible,	high-performance	
serving	system	for	machine	
learning	models,	designed	for	
production	environments.
• Easy	to	deploy	new	algorithms	
and	experiments,	while	
keeping	the	same	server	
architecture	and	APIs
Take	away
• There	are	4	steps:
• Step	1:	Assemble	the	graph	–
• 1.	Define	placeholders	for	input	and	output	
• 2.	Define	the	weights
• 3.	Define	the	inference	model
• 4.	Define	loss	function
• 5.	Define	optimizer	
• Step	2:	Train	the	Model
• Step	3:	Optimize	the	Model
The	world	has	too	many	problems	and	not	enough	
people	solving	them.
Thanks!
Questions?
@kuanhoong
https://www.linkedin.com/in/kuanhoong
kuanhoong@gmail.com
Demo
Slides	&	Codes	available	from	Github:	
http://bit.ly/TensorFlowMY

More Related Content

Explore and have fun with TensorFlow: An introductory to TensorFlow