SlideShare a Scribd company logo
1 of 38
Download to read offline
Robert John
GDE (GCP, ML)
@robert_thas
TensorFlow
What is TensorFlow and why do we use it?
TensorFlow is a numerical
computation library. It lets us
perform mathematical and
statistical operations on our
data.
Example
Predict the selling price of a house given the number of rooms
● Medv => y
● Rooms => x
● Constant => b
● Gradients => w
Formulate a Hypothesis
This hypothesis is called a model
Without TensorFlow
import pandas as pd
import numpy as np
train_df = pd.read_csv('/content/gdrive/My
Drive/boston/train.csv', index_col='ID')
train_df.head()
train_df[['rm', 'medv']].head()
y = train_df['medv'].values
train_df['constant'] = 1
columns = ['constant', 'rm']
x = train_df[columns].values
w = np.zeros((x.shape[1], 1))
y_pred = np.dot(x, w)
error = y - y_pred
print(error.shape)
squared_error = np.power(error, 2)
root_mean_squared_error = sqrt(squared_error.sum()) /
y_pred.shape[0]
print(root_mean_squared_error)
Training
costs = []
w_0_s = []
w_1_s = []
learning_rate = 1e-3
steps = 20
for a in range(steps):
w_0 = w[0][0]
w_1 = w[1][0]
# make prediction
y_pred = np.dot(x, w)
error = y - y_pred
error_squared = np.power(error, 2)
# cost function is Least Mean Squares
LMS = error_squared.sum() / (2 * y.shape[0])
costs.append(LMS)
w_0_s.append(w_0)
w_1_s.append(w_1)
# update
w_0 = w_0 + learning_rate/y.shape[0] * error.sum()
w_1 = w_1 + learning_rate/y.shape[0] * (error * x[1]).sum()
w[0][0] = w_0
w[1][0] = w_1
cost_df = pd.DataFrame({'cost': pd.Series(costs),
'w_0': pd.Series(w_0_s), 'w_1': pd.Series(w_1_s)})
cost_df['cost'].plot()
How good are the
predictions?
_w = [w_0, w_1]
_w = np.asarray(_w)
_x = train_df[['constant', 'rm']].values
y_pred = np.dot(_x, _w)
_p = pd.DataFrame(dict(actual=train_df['medv'].values,
predicted=y_pred.reshape(-1)))
_p.head()
How is TensorFlow different?
class Model(object):
def __init__(self):
self.W = None
self.b = None
def __call__(self, x):
if self.W == None:
self.W = tf.Variable(tf.random.normal(shape=(1, x.shape[1])))
if self.b == None:
self.b = tf.Variable(tf.random.normal(shape=(x.shape[0], 1)))
return tf.matmul(x, self.W, transpose_b=True) + self.b
model = Model()
output = model(tf.constant([3.0, 3.1, 1.9, 2.0, 2.5, 2.9],
shape=(3,2)))
print(output)
@tf.function
def loss(y_pred, y):
return tf.reduce_mean(tf.square(y-y_pred))
def train(model, x, y, alpha):
x = tf.convert_to_tensor(x, np.float32)
y = tf.convert_to_tensor(y, np.float32)
with tf.GradientTape() as t:
t.watch(x)
current_loss = loss(model(x), y)
#print(current_loss)
dW, db = t.gradient(current_loss, [model.W, model.b])
#print(dW, db)
model.W.assign_sub(alpha * dW)
model.b.assign_sub(alpha * db)
train_df = df.sample(frac=0.8,random_state=0)
test_df = df.drop(train_df.index)
columns = ['nox', 'rm', 'chas', 'dis', 'ptratio', 'lstat', 'rad']
X_train = train_df[columns].values
X_test = test_df[columns].values
y_train = train_df[['medv']].values
y_test = test_df[['medv']].values
epochs = 10
model = Model()
for i in range(epochs):
train(model, X_train, y_train, alpha=0.1)
print(model.W)
● Vectors & Matrices
● Matrix Dot Products
● Differentiation
What was all that?
We got introduced to
● Learning Rates
● Gradient Descent
● Training Epochs
All of that was Linear Regression. How
about Neural Networks?
import tensorflow as tf
from tensorflow import keras
model = keras.Sequential([
keras.layers.Dense(50, input_shape=(7,), activation='relu'),
keras.layers.Dense(50, activation='relu'),
keras.layers.Dense(50, activation='relu'),
keras.layers.Dropout(0.5),
keras.layers.Dense(1)
])
print(model.summary())
adam = keras.optimizers.Adam(0.001)
model.compile(optimizer=adam, loss='mse')
model.fit(X_train, y_train, epochs=2000, validation_split=0.1)
● Optimized operations
● Hardware acceleration
● Multiple languages/platforms
Benefits of using TensorFlow
● Layers
● Optimizers
● Loss Functions
● Feature Engineering
● Hyperparameter Tuning
● Model Optimization
● Transfer Learning
● Keras Preprocessing Layers
● Recommendations
● New features in tf.data
● Experimental Numpy support
What’s New in TensorFlow
● API Types (Keras, Estimators, etc)
● Originally graph-based vs. “pythonic”
Differences Between TensorFlow and Others
Learn More
Neural Networks and Deep Learning
http://neuralnetworksanddeeplearning.com/
Machine Learning Crash Course
https://developers.google.com/machine-learning/crash-course
TensorFlow
https://www.tensorflow.org/
Robert John
GDE (GCP, ML)
@robert_thas
Thank You!

More Related Content

What's hot (19)

SupportVectorRegression
SupportVectorRegressionSupportVectorRegression
SupportVectorRegression
 
Print input-presentation
Print input-presentationPrint input-presentation
Print input-presentation
 
Python programming : Standard Input and Output
Python programming : Standard Input and OutputPython programming : Standard Input and Output
Python programming : Standard Input and Output
 
Graph Plots in Matlab
Graph Plots in MatlabGraph Plots in Matlab
Graph Plots in Matlab
 
Cgm Lab Manual
Cgm Lab ManualCgm Lab Manual
Cgm Lab Manual
 
Recursion in C
Recursion in CRecursion in C
Recursion in C
 
Lr5
Lr5Lr5
Lr5
 
Programming Assignment Help
Programming Assignment HelpProgramming Assignment Help
Programming Assignment Help
 
Matlab Visualizing Data
Matlab Visualizing DataMatlab Visualizing Data
Matlab Visualizing Data
 
C++ extension methods
C++ extension methodsC++ extension methods
C++ extension methods
 
PYTHON. AM CALL Pricing Trees
PYTHON. AM CALL Pricing TreesPYTHON. AM CALL Pricing Trees
PYTHON. AM CALL Pricing Trees
 
Computer graphics
Computer graphics Computer graphics
Computer graphics
 
Computer graphics lab manual
Computer graphics lab manualComputer graphics lab manual
Computer graphics lab manual
 
Gentle Introduction to Functional Programming
Gentle Introduction to Functional ProgrammingGentle Introduction to Functional Programming
Gentle Introduction to Functional Programming
 
Arrays
ArraysArrays
Arrays
 
Day 4b iteration and functions for-loops.pptx
Day 4b   iteration and functions  for-loops.pptxDay 4b   iteration and functions  for-loops.pptx
Day 4b iteration and functions for-loops.pptx
 
Gauss seidal Matlab Code
Gauss seidal Matlab CodeGauss seidal Matlab Code
Gauss seidal Matlab Code
 
Project2
Project2Project2
Project2
 
Monte-carlo sim pricing EU call
Monte-carlo sim pricing EU callMonte-carlo sim pricing EU call
Monte-carlo sim pricing EU call
 

Similar to What is TensorFlow and why do we use it

Gentlest Introduction to Tensorflow - Part 2
Gentlest Introduction to Tensorflow - Part 2Gentlest Introduction to Tensorflow - Part 2
Gentlest Introduction to Tensorflow - Part 2Khor SoonHin
 
TensorFlow for IITians
TensorFlow for IITiansTensorFlow for IITians
TensorFlow for IITiansAshish Bansal
 
TensorFlow Dev Summit 2018 Extended: TensorFlow Eager Execution
TensorFlow Dev Summit 2018 Extended: TensorFlow Eager ExecutionTensorFlow Dev Summit 2018 Extended: TensorFlow Eager Execution
TensorFlow Dev Summit 2018 Extended: TensorFlow Eager ExecutionTaegyun Jeon
 
Introduction to Tensorflow
Introduction to TensorflowIntroduction to Tensorflow
Introduction to TensorflowTzar Umang
 
Explanation on Tensorflow example -Deep mnist for expert
Explanation on Tensorflow example -Deep mnist for expertExplanation on Tensorflow example -Deep mnist for expert
Explanation on Tensorflow example -Deep mnist for expert홍배 김
 
Sergey Shelpuk & Olha Romaniuk - “Deep learning, Tensorflow, and Fashion: how...
Sergey Shelpuk & Olha Romaniuk - “Deep learning, Tensorflow, and Fashion: how...Sergey Shelpuk & Olha Romaniuk - “Deep learning, Tensorflow, and Fashion: how...
Sergey Shelpuk & Olha Romaniuk - “Deep learning, Tensorflow, and Fashion: how...Lviv Startup Club
 
Lucio Floretta - TensorFlow and Deep Learning without a PhD - Codemotion Mila...
Lucio Floretta - TensorFlow and Deep Learning without a PhD - Codemotion Mila...Lucio Floretta - TensorFlow and Deep Learning without a PhD - Codemotion Mila...
Lucio Floretta - TensorFlow and Deep Learning without a PhD - Codemotion Mila...Codemotion
 
TensorFlow in Practice
TensorFlow in PracticeTensorFlow in Practice
TensorFlow in Practiceindico data
 
ggtimeseries-->ggplot2 extensions
ggtimeseries-->ggplot2 extensions ggtimeseries-->ggplot2 extensions
ggtimeseries-->ggplot2 extensions Dr. Volkan OBAN
 
Need help filling out the missing sections of this code- the sections.docx
Need help filling out the missing sections of this code- the sections.docxNeed help filling out the missing sections of this code- the sections.docx
Need help filling out the missing sections of this code- the sections.docxlauracallander
 
Basic R Data Manipulation
Basic R Data ManipulationBasic R Data Manipulation
Basic R Data ManipulationChu An
 
Tip Top Typing - A Look at Python Typing
Tip Top Typing - A Look at Python TypingTip Top Typing - A Look at Python Typing
Tip Top Typing - A Look at Python TypingPatrick Viafore
 
Introduction to Machine Learning
Introduction to Machine LearningIntroduction to Machine Learning
Introduction to Machine LearningBig_Data_Ukraine
 
Generic Functional Programming with Type Classes
Generic Functional Programming with Type ClassesGeneric Functional Programming with Type Classes
Generic Functional Programming with Type ClassesTapio Rautonen
 
Working with tf.data (TF 2)
Working with tf.data (TF 2)Working with tf.data (TF 2)
Working with tf.data (TF 2)Oswald Campesato
 
Scala Functional Patterns
Scala Functional PatternsScala Functional Patterns
Scala Functional Patternsleague
 
Pythonbrasil - 2018 - Acelerando Soluções com GPU
Pythonbrasil - 2018 - Acelerando Soluções com GPUPythonbrasil - 2018 - Acelerando Soluções com GPU
Pythonbrasil - 2018 - Acelerando Soluções com GPUPaulo Sergio Lemes Queiroz
 
Building Machine Learning Algorithms on Apache Spark: Scaling Out and Up with...
Building Machine Learning Algorithms on Apache Spark: Scaling Out and Up with...Building Machine Learning Algorithms on Apache Spark: Scaling Out and Up with...
Building Machine Learning Algorithms on Apache Spark: Scaling Out and Up with...Databricks
 
Paolo Galeone - Dissecting tf.function to discover auto graph strengths and s...
Paolo Galeone - Dissecting tf.function to discover auto graph strengths and s...Paolo Galeone - Dissecting tf.function to discover auto graph strengths and s...
Paolo Galeone - Dissecting tf.function to discover auto graph strengths and s...MeetupDataScienceRoma
 

Similar to What is TensorFlow and why do we use it (20)

Gentlest Introduction to Tensorflow - Part 2
Gentlest Introduction to Tensorflow - Part 2Gentlest Introduction to Tensorflow - Part 2
Gentlest Introduction to Tensorflow - Part 2
 
Google TensorFlow Tutorial
Google TensorFlow TutorialGoogle TensorFlow Tutorial
Google TensorFlow Tutorial
 
TensorFlow for IITians
TensorFlow for IITiansTensorFlow for IITians
TensorFlow for IITians
 
TensorFlow Dev Summit 2018 Extended: TensorFlow Eager Execution
TensorFlow Dev Summit 2018 Extended: TensorFlow Eager ExecutionTensorFlow Dev Summit 2018 Extended: TensorFlow Eager Execution
TensorFlow Dev Summit 2018 Extended: TensorFlow Eager Execution
 
Introduction to Tensorflow
Introduction to TensorflowIntroduction to Tensorflow
Introduction to Tensorflow
 
Explanation on Tensorflow example -Deep mnist for expert
Explanation on Tensorflow example -Deep mnist for expertExplanation on Tensorflow example -Deep mnist for expert
Explanation on Tensorflow example -Deep mnist for expert
 
Sergey Shelpuk & Olha Romaniuk - “Deep learning, Tensorflow, and Fashion: how...
Sergey Shelpuk & Olha Romaniuk - “Deep learning, Tensorflow, and Fashion: how...Sergey Shelpuk & Olha Romaniuk - “Deep learning, Tensorflow, and Fashion: how...
Sergey Shelpuk & Olha Romaniuk - “Deep learning, Tensorflow, and Fashion: how...
 
Lucio Floretta - TensorFlow and Deep Learning without a PhD - Codemotion Mila...
Lucio Floretta - TensorFlow and Deep Learning without a PhD - Codemotion Mila...Lucio Floretta - TensorFlow and Deep Learning without a PhD - Codemotion Mila...
Lucio Floretta - TensorFlow and Deep Learning without a PhD - Codemotion Mila...
 
TensorFlow in Practice
TensorFlow in PracticeTensorFlow in Practice
TensorFlow in Practice
 
ggtimeseries-->ggplot2 extensions
ggtimeseries-->ggplot2 extensions ggtimeseries-->ggplot2 extensions
ggtimeseries-->ggplot2 extensions
 
Need help filling out the missing sections of this code- the sections.docx
Need help filling out the missing sections of this code- the sections.docxNeed help filling out the missing sections of this code- the sections.docx
Need help filling out the missing sections of this code- the sections.docx
 
Basic R Data Manipulation
Basic R Data ManipulationBasic R Data Manipulation
Basic R Data Manipulation
 
Tip Top Typing - A Look at Python Typing
Tip Top Typing - A Look at Python TypingTip Top Typing - A Look at Python Typing
Tip Top Typing - A Look at Python Typing
 
Introduction to Machine Learning
Introduction to Machine LearningIntroduction to Machine Learning
Introduction to Machine Learning
 
Generic Functional Programming with Type Classes
Generic Functional Programming with Type ClassesGeneric Functional Programming with Type Classes
Generic Functional Programming with Type Classes
 
Working with tf.data (TF 2)
Working with tf.data (TF 2)Working with tf.data (TF 2)
Working with tf.data (TF 2)
 
Scala Functional Patterns
Scala Functional PatternsScala Functional Patterns
Scala Functional Patterns
 
Pythonbrasil - 2018 - Acelerando Soluções com GPU
Pythonbrasil - 2018 - Acelerando Soluções com GPUPythonbrasil - 2018 - Acelerando Soluções com GPU
Pythonbrasil - 2018 - Acelerando Soluções com GPU
 
Building Machine Learning Algorithms on Apache Spark: Scaling Out and Up with...
Building Machine Learning Algorithms on Apache Spark: Scaling Out and Up with...Building Machine Learning Algorithms on Apache Spark: Scaling Out and Up with...
Building Machine Learning Algorithms on Apache Spark: Scaling Out and Up with...
 
Paolo Galeone - Dissecting tf.function to discover auto graph strengths and s...
Paolo Galeone - Dissecting tf.function to discover auto graph strengths and s...Paolo Galeone - Dissecting tf.function to discover auto graph strengths and s...
Paolo Galeone - Dissecting tf.function to discover auto graph strengths and s...
 

More from Robert John

DevFest 2022 Nairobi - Considerations for Deploying ML Models on Edge Devices...
DevFest 2022 Nairobi - Considerations for Deploying ML Models on Edge Devices...DevFest 2022 Nairobi - Considerations for Deploying ML Models on Edge Devices...
DevFest 2022 Nairobi - Considerations for Deploying ML Models on Edge Devices...Robert John
 
DevFest 2022 - Nairobi ML Keynote.pptx
DevFest 2022 - Nairobi ML Keynote.pptxDevFest 2022 - Nairobi ML Keynote.pptx
DevFest 2022 - Nairobi ML Keynote.pptxRobert John
 
Arduino Certification
Arduino CertificationArduino Certification
Arduino CertificationRobert John
 
Fundamentals of cloud computing
Fundamentals of cloud computingFundamentals of cloud computing
Fundamentals of cloud computingRobert John
 
What is Google Cloud Good For at DevFestInspire 2021
What is Google Cloud Good For at DevFestInspire 2021What is Google Cloud Good For at DevFestInspire 2021
What is Google Cloud Good For at DevFestInspire 2021Robert John
 
TinyML at DevFestLagos21
TinyML at DevFestLagos21TinyML at DevFestLagos21
TinyML at DevFestLagos21Robert John
 
TinyML: Machine Learning for Microcontrollers
TinyML: Machine Learning for MicrocontrollersTinyML: Machine Learning for Microcontrollers
TinyML: Machine Learning for MicrocontrollersRobert John
 

More from Robert John (7)

DevFest 2022 Nairobi - Considerations for Deploying ML Models on Edge Devices...
DevFest 2022 Nairobi - Considerations for Deploying ML Models on Edge Devices...DevFest 2022 Nairobi - Considerations for Deploying ML Models on Edge Devices...
DevFest 2022 Nairobi - Considerations for Deploying ML Models on Edge Devices...
 
DevFest 2022 - Nairobi ML Keynote.pptx
DevFest 2022 - Nairobi ML Keynote.pptxDevFest 2022 - Nairobi ML Keynote.pptx
DevFest 2022 - Nairobi ML Keynote.pptx
 
Arduino Certification
Arduino CertificationArduino Certification
Arduino Certification
 
Fundamentals of cloud computing
Fundamentals of cloud computingFundamentals of cloud computing
Fundamentals of cloud computing
 
What is Google Cloud Good For at DevFestInspire 2021
What is Google Cloud Good For at DevFestInspire 2021What is Google Cloud Good For at DevFestInspire 2021
What is Google Cloud Good For at DevFestInspire 2021
 
TinyML at DevFestLagos21
TinyML at DevFestLagos21TinyML at DevFestLagos21
TinyML at DevFestLagos21
 
TinyML: Machine Learning for Microcontrollers
TinyML: Machine Learning for MicrocontrollersTinyML: Machine Learning for Microcontrollers
TinyML: Machine Learning for Microcontrollers
 

Recently uploaded

How we prevented account sharing with MFA
How we prevented account sharing with MFAHow we prevented account sharing with MFA
How we prevented account sharing with MFAAndrei Kaleshka
 
B2 Creative Industry Response Evaluation.docx
B2 Creative Industry Response Evaluation.docxB2 Creative Industry Response Evaluation.docx
B2 Creative Industry Response Evaluation.docxStephen266013
 
毕业文凭制作#回国入职#diploma#degree澳洲中央昆士兰大学毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#degree
毕业文凭制作#回国入职#diploma#degree澳洲中央昆士兰大学毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#degree毕业文凭制作#回国入职#diploma#degree澳洲中央昆士兰大学毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#degree
毕业文凭制作#回国入职#diploma#degree澳洲中央昆士兰大学毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#degreeyuu sss
 
办理(Vancouver毕业证书)加拿大温哥华岛大学毕业证成绩单原版一比一
办理(Vancouver毕业证书)加拿大温哥华岛大学毕业证成绩单原版一比一办理(Vancouver毕业证书)加拿大温哥华岛大学毕业证成绩单原版一比一
办理(Vancouver毕业证书)加拿大温哥华岛大学毕业证成绩单原版一比一F La
 
Building on a FAIRly Strong Foundation to Connect Academic Research to Transl...
Building on a FAIRly Strong Foundation to Connect Academic Research to Transl...Building on a FAIRly Strong Foundation to Connect Academic Research to Transl...
Building on a FAIRly Strong Foundation to Connect Academic Research to Transl...Jack DiGiovanna
 
INTERNSHIP ON PURBASHA COMPOSITE TEX LTD
INTERNSHIP ON PURBASHA COMPOSITE TEX LTDINTERNSHIP ON PURBASHA COMPOSITE TEX LTD
INTERNSHIP ON PURBASHA COMPOSITE TEX LTDRafezzaman
 
Kantar AI Summit- Under Embargo till Wednesday, 24th April 2024, 4 PM, IST.pdf
Kantar AI Summit- Under Embargo till Wednesday, 24th April 2024, 4 PM, IST.pdfKantar AI Summit- Under Embargo till Wednesday, 24th April 2024, 4 PM, IST.pdf
Kantar AI Summit- Under Embargo till Wednesday, 24th April 2024, 4 PM, IST.pdfSocial Samosa
 
PKS-TGC-1084-630 - Stage 1 Proposal.pptx
PKS-TGC-1084-630 - Stage 1 Proposal.pptxPKS-TGC-1084-630 - Stage 1 Proposal.pptx
PKS-TGC-1084-630 - Stage 1 Proposal.pptxPramod Kumar Srivastava
 
vip Sarai Rohilla Call Girls 9999965857 Call or WhatsApp Now Book
vip Sarai Rohilla Call Girls 9999965857 Call or WhatsApp Now Bookvip Sarai Rohilla Call Girls 9999965857 Call or WhatsApp Now Book
vip Sarai Rohilla Call Girls 9999965857 Call or WhatsApp Now Bookmanojkuma9823
 
Call Girls in Defence Colony Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Defence Colony Delhi 💯Call Us 🔝8264348440🔝Call Girls in Defence Colony Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Defence Colony Delhi 💯Call Us 🔝8264348440🔝soniya singh
 
VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130
VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130
VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130Suhani Kapoor
 
Industrialised data - the key to AI success.pdf
Industrialised data - the key to AI success.pdfIndustrialised data - the key to AI success.pdf
Industrialised data - the key to AI success.pdfLars Albertsson
 
Saket, (-DELHI )+91-9654467111-(=)CHEAP Call Girls in Escorts Service Saket C...
Saket, (-DELHI )+91-9654467111-(=)CHEAP Call Girls in Escorts Service Saket C...Saket, (-DELHI )+91-9654467111-(=)CHEAP Call Girls in Escorts Service Saket C...
Saket, (-DELHI )+91-9654467111-(=)CHEAP Call Girls in Escorts Service Saket C...Sapana Sha
 
Indian Call Girls in Abu Dhabi O5286O24O8 Call Girls in Abu Dhabi By Independ...
Indian Call Girls in Abu Dhabi O5286O24O8 Call Girls in Abu Dhabi By Independ...Indian Call Girls in Abu Dhabi O5286O24O8 Call Girls in Abu Dhabi By Independ...
Indian Call Girls in Abu Dhabi O5286O24O8 Call Girls in Abu Dhabi By Independ...dajasot375
 
Dubai Call Girls Wifey O52&786472 Call Girls Dubai
Dubai Call Girls Wifey O52&786472 Call Girls DubaiDubai Call Girls Wifey O52&786472 Call Girls Dubai
Dubai Call Girls Wifey O52&786472 Call Girls Dubaihf8803863
 
科罗拉多大学波尔得分校毕业证学位证成绩单-可办理
科罗拉多大学波尔得分校毕业证学位证成绩单-可办理科罗拉多大学波尔得分校毕业证学位证成绩单-可办理
科罗拉多大学波尔得分校毕业证学位证成绩单-可办理e4aez8ss
 
办理学位证中佛罗里达大学毕业证,UCF成绩单原版一比一
办理学位证中佛罗里达大学毕业证,UCF成绩单原版一比一办理学位证中佛罗里达大学毕业证,UCF成绩单原版一比一
办理学位证中佛罗里达大学毕业证,UCF成绩单原版一比一F sss
 
High Class Call Girls Noida Sector 39 Aarushi 🔝8264348440🔝 Independent Escort...
High Class Call Girls Noida Sector 39 Aarushi 🔝8264348440🔝 Independent Escort...High Class Call Girls Noida Sector 39 Aarushi 🔝8264348440🔝 Independent Escort...
High Class Call Girls Noida Sector 39 Aarushi 🔝8264348440🔝 Independent Escort...soniya singh
 
Call Girls In Dwarka 9654467111 Escorts Service
Call Girls In Dwarka 9654467111 Escorts ServiceCall Girls In Dwarka 9654467111 Escorts Service
Call Girls In Dwarka 9654467111 Escorts ServiceSapana Sha
 

Recently uploaded (20)

How we prevented account sharing with MFA
How we prevented account sharing with MFAHow we prevented account sharing with MFA
How we prevented account sharing with MFA
 
E-Commerce Order PredictionShraddha Kamble.pptx
E-Commerce Order PredictionShraddha Kamble.pptxE-Commerce Order PredictionShraddha Kamble.pptx
E-Commerce Order PredictionShraddha Kamble.pptx
 
B2 Creative Industry Response Evaluation.docx
B2 Creative Industry Response Evaluation.docxB2 Creative Industry Response Evaluation.docx
B2 Creative Industry Response Evaluation.docx
 
毕业文凭制作#回国入职#diploma#degree澳洲中央昆士兰大学毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#degree
毕业文凭制作#回国入职#diploma#degree澳洲中央昆士兰大学毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#degree毕业文凭制作#回国入职#diploma#degree澳洲中央昆士兰大学毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#degree
毕业文凭制作#回国入职#diploma#degree澳洲中央昆士兰大学毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#degree
 
办理(Vancouver毕业证书)加拿大温哥华岛大学毕业证成绩单原版一比一
办理(Vancouver毕业证书)加拿大温哥华岛大学毕业证成绩单原版一比一办理(Vancouver毕业证书)加拿大温哥华岛大学毕业证成绩单原版一比一
办理(Vancouver毕业证书)加拿大温哥华岛大学毕业证成绩单原版一比一
 
Building on a FAIRly Strong Foundation to Connect Academic Research to Transl...
Building on a FAIRly Strong Foundation to Connect Academic Research to Transl...Building on a FAIRly Strong Foundation to Connect Academic Research to Transl...
Building on a FAIRly Strong Foundation to Connect Academic Research to Transl...
 
INTERNSHIP ON PURBASHA COMPOSITE TEX LTD
INTERNSHIP ON PURBASHA COMPOSITE TEX LTDINTERNSHIP ON PURBASHA COMPOSITE TEX LTD
INTERNSHIP ON PURBASHA COMPOSITE TEX LTD
 
Kantar AI Summit- Under Embargo till Wednesday, 24th April 2024, 4 PM, IST.pdf
Kantar AI Summit- Under Embargo till Wednesday, 24th April 2024, 4 PM, IST.pdfKantar AI Summit- Under Embargo till Wednesday, 24th April 2024, 4 PM, IST.pdf
Kantar AI Summit- Under Embargo till Wednesday, 24th April 2024, 4 PM, IST.pdf
 
PKS-TGC-1084-630 - Stage 1 Proposal.pptx
PKS-TGC-1084-630 - Stage 1 Proposal.pptxPKS-TGC-1084-630 - Stage 1 Proposal.pptx
PKS-TGC-1084-630 - Stage 1 Proposal.pptx
 
vip Sarai Rohilla Call Girls 9999965857 Call or WhatsApp Now Book
vip Sarai Rohilla Call Girls 9999965857 Call or WhatsApp Now Bookvip Sarai Rohilla Call Girls 9999965857 Call or WhatsApp Now Book
vip Sarai Rohilla Call Girls 9999965857 Call or WhatsApp Now Book
 
Call Girls in Defence Colony Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Defence Colony Delhi 💯Call Us 🔝8264348440🔝Call Girls in Defence Colony Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Defence Colony Delhi 💯Call Us 🔝8264348440🔝
 
VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130
VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130
VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130
 
Industrialised data - the key to AI success.pdf
Industrialised data - the key to AI success.pdfIndustrialised data - the key to AI success.pdf
Industrialised data - the key to AI success.pdf
 
Saket, (-DELHI )+91-9654467111-(=)CHEAP Call Girls in Escorts Service Saket C...
Saket, (-DELHI )+91-9654467111-(=)CHEAP Call Girls in Escorts Service Saket C...Saket, (-DELHI )+91-9654467111-(=)CHEAP Call Girls in Escorts Service Saket C...
Saket, (-DELHI )+91-9654467111-(=)CHEAP Call Girls in Escorts Service Saket C...
 
Indian Call Girls in Abu Dhabi O5286O24O8 Call Girls in Abu Dhabi By Independ...
Indian Call Girls in Abu Dhabi O5286O24O8 Call Girls in Abu Dhabi By Independ...Indian Call Girls in Abu Dhabi O5286O24O8 Call Girls in Abu Dhabi By Independ...
Indian Call Girls in Abu Dhabi O5286O24O8 Call Girls in Abu Dhabi By Independ...
 
Dubai Call Girls Wifey O52&786472 Call Girls Dubai
Dubai Call Girls Wifey O52&786472 Call Girls DubaiDubai Call Girls Wifey O52&786472 Call Girls Dubai
Dubai Call Girls Wifey O52&786472 Call Girls Dubai
 
科罗拉多大学波尔得分校毕业证学位证成绩单-可办理
科罗拉多大学波尔得分校毕业证学位证成绩单-可办理科罗拉多大学波尔得分校毕业证学位证成绩单-可办理
科罗拉多大学波尔得分校毕业证学位证成绩单-可办理
 
办理学位证中佛罗里达大学毕业证,UCF成绩单原版一比一
办理学位证中佛罗里达大学毕业证,UCF成绩单原版一比一办理学位证中佛罗里达大学毕业证,UCF成绩单原版一比一
办理学位证中佛罗里达大学毕业证,UCF成绩单原版一比一
 
High Class Call Girls Noida Sector 39 Aarushi 🔝8264348440🔝 Independent Escort...
High Class Call Girls Noida Sector 39 Aarushi 🔝8264348440🔝 Independent Escort...High Class Call Girls Noida Sector 39 Aarushi 🔝8264348440🔝 Independent Escort...
High Class Call Girls Noida Sector 39 Aarushi 🔝8264348440🔝 Independent Escort...
 
Call Girls In Dwarka 9654467111 Escorts Service
Call Girls In Dwarka 9654467111 Escorts ServiceCall Girls In Dwarka 9654467111 Escorts Service
Call Girls In Dwarka 9654467111 Escorts Service
 

What is TensorFlow and why do we use it

  • 1. Robert John GDE (GCP, ML) @robert_thas TensorFlow What is TensorFlow and why do we use it?
  • 2. TensorFlow is a numerical computation library. It lets us perform mathematical and statistical operations on our data.
  • 3. Example Predict the selling price of a house given the number of rooms
  • 4.
  • 5.
  • 6.
  • 7. ● Medv => y ● Rooms => x ● Constant => b ● Gradients => w Formulate a Hypothesis This hypothesis is called a model
  • 9. import pandas as pd import numpy as np train_df = pd.read_csv('/content/gdrive/My Drive/boston/train.csv', index_col='ID') train_df.head()
  • 10.
  • 12. y = train_df['medv'].values train_df['constant'] = 1 columns = ['constant', 'rm'] x = train_df[columns].values w = np.zeros((x.shape[1], 1)) y_pred = np.dot(x, w)
  • 13. error = y - y_pred print(error.shape) squared_error = np.power(error, 2) root_mean_squared_error = sqrt(squared_error.sum()) / y_pred.shape[0] print(root_mean_squared_error)
  • 15. costs = [] w_0_s = [] w_1_s = [] learning_rate = 1e-3 steps = 20
  • 16. for a in range(steps): w_0 = w[0][0] w_1 = w[1][0] # make prediction y_pred = np.dot(x, w) error = y - y_pred error_squared = np.power(error, 2)
  • 17. # cost function is Least Mean Squares LMS = error_squared.sum() / (2 * y.shape[0]) costs.append(LMS) w_0_s.append(w_0) w_1_s.append(w_1) # update w_0 = w_0 + learning_rate/y.shape[0] * error.sum() w_1 = w_1 + learning_rate/y.shape[0] * (error * x[1]).sum() w[0][0] = w_0 w[1][0] = w_1
  • 18. cost_df = pd.DataFrame({'cost': pd.Series(costs), 'w_0': pd.Series(w_0_s), 'w_1': pd.Series(w_1_s)}) cost_df['cost'].plot()
  • 19. How good are the predictions?
  • 20. _w = [w_0, w_1] _w = np.asarray(_w) _x = train_df[['constant', 'rm']].values y_pred = np.dot(_x, _w) _p = pd.DataFrame(dict(actual=train_df['medv'].values, predicted=y_pred.reshape(-1))) _p.head()
  • 21.
  • 22. How is TensorFlow different?
  • 23. class Model(object): def __init__(self): self.W = None self.b = None def __call__(self, x): if self.W == None: self.W = tf.Variable(tf.random.normal(shape=(1, x.shape[1]))) if self.b == None: self.b = tf.Variable(tf.random.normal(shape=(x.shape[0], 1))) return tf.matmul(x, self.W, transpose_b=True) + self.b
  • 24. model = Model() output = model(tf.constant([3.0, 3.1, 1.9, 2.0, 2.5, 2.9], shape=(3,2))) print(output)
  • 25. @tf.function def loss(y_pred, y): return tf.reduce_mean(tf.square(y-y_pred))
  • 26. def train(model, x, y, alpha): x = tf.convert_to_tensor(x, np.float32) y = tf.convert_to_tensor(y, np.float32) with tf.GradientTape() as t: t.watch(x) current_loss = loss(model(x), y) #print(current_loss) dW, db = t.gradient(current_loss, [model.W, model.b]) #print(dW, db) model.W.assign_sub(alpha * dW) model.b.assign_sub(alpha * db)
  • 27. train_df = df.sample(frac=0.8,random_state=0) test_df = df.drop(train_df.index) columns = ['nox', 'rm', 'chas', 'dis', 'ptratio', 'lstat', 'rad'] X_train = train_df[columns].values X_test = test_df[columns].values y_train = train_df[['medv']].values y_test = test_df[['medv']].values
  • 28. epochs = 10 model = Model() for i in range(epochs): train(model, X_train, y_train, alpha=0.1) print(model.W)
  • 29. ● Vectors & Matrices ● Matrix Dot Products ● Differentiation What was all that? We got introduced to ● Learning Rates ● Gradient Descent ● Training Epochs
  • 30. All of that was Linear Regression. How about Neural Networks?
  • 31. import tensorflow as tf from tensorflow import keras model = keras.Sequential([ keras.layers.Dense(50, input_shape=(7,), activation='relu'), keras.layers.Dense(50, activation='relu'), keras.layers.Dense(50, activation='relu'), keras.layers.Dropout(0.5), keras.layers.Dense(1) ]) print(model.summary())
  • 32.
  • 33. adam = keras.optimizers.Adam(0.001) model.compile(optimizer=adam, loss='mse') model.fit(X_train, y_train, epochs=2000, validation_split=0.1)
  • 34. ● Optimized operations ● Hardware acceleration ● Multiple languages/platforms Benefits of using TensorFlow ● Layers ● Optimizers ● Loss Functions ● Feature Engineering ● Hyperparameter Tuning ● Model Optimization ● Transfer Learning
  • 35. ● Keras Preprocessing Layers ● Recommendations ● New features in tf.data ● Experimental Numpy support What’s New in TensorFlow
  • 36. ● API Types (Keras, Estimators, etc) ● Originally graph-based vs. “pythonic” Differences Between TensorFlow and Others
  • 37. Learn More Neural Networks and Deep Learning http://neuralnetworksanddeeplearning.com/ Machine Learning Crash Course https://developers.google.com/machine-learning/crash-course TensorFlow https://www.tensorflow.org/
  • 38. Robert John GDE (GCP, ML) @robert_thas Thank You!