Download presentation
Presentation is loading. Please wait.
1
Tensorflow Tutorial Homin Yoon
2
What is Tensorflow? 01 Is a Open source software library for numerical computation using data flow graphs. Nodes in the graph represent mathematical operations, while the graph edges represent the multidimensional data arrays (tensors) Open source software library for numerical computation It uses data flow graphs.(Node : operation, Edge : tensor)
3
What is Tensorflow? Data Flow Graph
01 Data Flow Graph Nodes in the graph represent mathematical operations Edges describe the i/o relationships between nodes Data edges carry dynamically-sized multidimensional data arrays, or tensors Is a Open source software library for numerical computation using data flow graphs. Nodes in the graph represent mathematical operations, while the graph edges represent the multidimensional data arrays (tensors)
4
What is Tensorflow? Machine Learning requires complex computations.
01 Is a Open source software library for numerical computation using data flow graphs. Nodes in the graph represent mathematical operations, while the graph edges represent the multidimensional data arrays (tensors) Machine Learning requires complex computations. They are hard to display.(Tensor board)
5
Installation Tensorflow suits with Linux
02 Tensorflow suits with Linux Virtual machine is not helpful because it is impossible to access process unit when it has compuation Therefore, I have installed ubuntu by using dual boot
6
Installation We have to install python 2.7version
02 We have to install python 2.7version Because newest version doesn’t support all library To import tensorflow, we should install anaconda Otherwise, there would be import error
7
Installation If you want to use GPU for computation for ML
02 If you want to use GPU for computation for ML You have to install CUDA tool kit. CUDA is Compute Unified Device Architecture Just for CPU computation, cuda toolkit isn’t needed
8
Installation 02 CUDNN can boost GPU so that computation speed is increased even higher You should give a permission of CUDNN library To every user in Ubuntu
9
Installation Finally, Only tensorflow package is left
02 Finally, Only tensorflow package is left Download tensorflow source file and compile with Bazel Compiler made by google
10
Installation Platform: Ubuntu16.04(Linux)
02 Platform: Ubuntu16.04(Linux) Language & tool: Python2.7 & Anaconda For GPU: CUDA Toolkit & CUDNN Complier for tensorflow package: Bazel Now, we can START TENSORFLOW
11
Simple code(multiply)
03 import tensorflow as tf a = tf.placeholder("float") b = tf.placeholder("float") y = tf.mul(a, b) sess = tf.Session() print sess.run(y, feed_dict={a: 3, b: 3})
12
Simple code(multiply)
03 Operation Description tf.add sum tf.sub substraction tf.mul multiplication tf.div division tf.mod module tf.abs return the absolute value tf.neg return negative value
13
Simple code(multiply)
03 Operations & Kernels An operation has a name and represents an abstract computation (e.g., “matrix multiply”, or “add”) A kernel is a particular implementation of operation that can be run on a particular device (e.g., CPU or GPU).
14
Simple code(multiply)
03 Operations groups Operations Maths Add, Sub, Mul, … Array Concat, Slice, Split, Constant, … Matrix MatMul, MatrixInverse, MatrixDeterminant Neuronal Network SoftMax, Sigmoid, ReLU, Convolution2D, MaxPool Flow control Merge, Switch, Enter, Leave, NextIteration
15
Linear Regression 04
16
Linear Regression 04 linear regression is an approach for modeling the relationship between a scalar dependent variable y and one or more variables denoted X.
17
Linear Regression y = W * x + b y = 0.1 * x + 0.3 Cost function:
04 y = W * x + b y = 0.1 * x + 0.3 Cost function: Mean square error It uses gradient descent
18
Linear Regression 04
19
Clustering Tensor Shape, Rank and Dimension
05 Tensor Shape, Rank and Dimension Shape Rank Dimension-Number [] D [D0] D [D0, D1] D [D0, D1, D2] D … … … [D0, D1, ... Dn] n n-D
20
Clustering Data Storage in TensorFlow
05 Data Storage in TensorFlow Data files ://github.com/jorditorresBCN/ LibroTensorFlow/blob/master/input_data.py Memory: • Constants tf.constant(…) • Variables tf.Variable(…) Python code : Placeholders • feed_dict parameter
21
Clustering import tensorflow as tf a = tf.placeholder("float")
05 import tensorflow as tf a = tf.placeholder("float") b = tf.placeholder("float") y = tf.mul(a, b) sess = tf.Session() print sess.run(y, feed_dict={a: 3, b: 3})
22
Clustering K-mean Algorithm
05 K-mean Algorithm As it is a heuristic algorithm, there is no guarantee that it will converge to the global optimum, and the result may depend on the initial clusters. As the algorithm is usually very fast, it is common to run it multiple times with different starting conditions.
23
Clustering 05 vectors = tf.constant(conjunto_puntos) k = 4
centroides = tf.Variable(tf.slice(tf.random_shuffle(vectors),[0,0],[k,-1])) expanded_vectors = tf.expand_dims(vectors, 0) expanded_centroides = tf.expand_dims(centroides, 1) assignments = tf.argmin(tf.reduce_sum(tf.square(tf.sub(expanded_vectors, expanded_centroides)), 2), 0) means = tf.concat(0, [tf.reduce_mean(tf.gather(vectors, tf.reshape(tf.where( tf.equal(assignments, c)),[1,-1])), reduction_indices=[1]) for c in xrange(k)]) update_centroides = tf.assign(centroides, means) init_op = tf.initialize_all_variables() sess = tf.Session() sess.run(init_op) for step in xrange(100): _, centroid_values, assignment_values = sess.run([update_centroides centroides, assignments])
24
Clustering K-mean Algorithm
05 K-mean Algorithm Initial step (step 0): determines an initial set of K centroids. Allocation step (step 1): assigns each observation to the nearest group. Update step (step 2): calculates the new centroids for each new group
25
Clustering K-mean Algorithm
05 K-mean Algorithm Initial step (step 0): determines an initial set of K centroids. Allocation step (step 1): assigns each observation to the nearest group. Update step (step 2): calculates the new centroids for each new group
26
Clustering K-mean Algorithm There are two tensors
05 K-mean Algorithm There are two tensors Vectors(2000 number of distributed point) Centroid(4 centroid)
27
Clustering K-mean Algorithm print centroid_values
05 K-mean Algorithm print centroid_values [[ e e-01] [ e e-01] [ e e-01] [ e e-01]]
28
Thank you.
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.