32,39 €
The TensorFlow Developer Certificate Guide is an indispensable resource for machine learning enthusiasts and data professionals seeking to master TensorFlow and validate their skills by earning the certification. This practical guide equips you with the skills and knowledge necessary to build robust deep learning models that effectively tackle real-world challenges across diverse industries.
You’ll embark on a journey of skill acquisition through easy-to-follow, step-by-step explanations and practical examples, mastering the craft of building sophisticated models using TensorFlow 2.x and overcoming common hurdles such as overfitting and data augmentation. With this book, you’ll discover a wide range of practical applications, including computer vision, natural language processing, and time series prediction.
To prepare you for the TensorFlow Developer Certificate exam, it offers comprehensive coverage of exam topics, including image classification, natural language processing (NLP), and time series analysis. With the TensorFlow certification, you’ll be primed to tackle a broad spectrum of business problems and advance your career in the exciting field of machine learning. Whether you are a novice or an experienced developer, this guide will propel you to achieve your aspirations and become a highly skilled TensorFlow professional.
Das E-Book können Sie in Legimi-Apps oder einer beliebigen App lesen, die das folgende Format unterstützen:
Seitenzahl: 452
Veröffentlichungsjahr: 2023
Efficiently tackle deep learning and ML problems to ace the Developer Certificate exam
Oluwole Fagbohun
BIRMINGHAM—MUMBAI
Copyright © 2023 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing or its dealers and distributors, will be held liable for any damages caused or alleged to have been caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.
Group Product Manager: Ali Abidi
Publishing Product Manager: Anant Jain
Book Project Manager: Farheen Fathima, Aparna Ravikumar Nair
Content Development Editor: Manikandan Kurup
Technical Editor: Sweety Pagaria
Copy Editor: Safis Editing
Proofreader: Safis Editing
Indexer: Manju Arasan
Production Designer: Prashant Ghare, Alishon Mendonca
DevRel Marketing Coordinator: Vinishka Kalra
First published: September 2023
Production reference: 2201023
Published by Packt Publishing Ltd.
Grosvenor House
11 St Paul’s Square
Birmingham
B3 1RB, UK.
ISBN 978-1-80324-013-8
www.packtpub.com
The book is dedicated to everyone who has supported me this far especially my parents, my siblings and of course my in-laws. Special thanks goes to my wife and children for their support through those long nights and early morning of writing this book.
Oluwole Fagbohun, a certified TensorFlow developer and machine learning engineer, is currently working as Vice President of Engineering and Environmental Data at ChangeBlock, where he is spearheading the fight against climate change with machine learning. Beyond his role at ChangeBlock, Oluwole is the founder of Readrly an EdTech startup employing AI to enhance children’s reading skills, offering engaging and gamified learning experiences.
Ashish Patel is a seasoned author, data scientist, and researcher with over 11+ years of experience in data science and research. Currently, he holds the position of Sr. AWS AI ML Solution Architect (Chief Data Scientist) at IBM India Pvt Ltd. He has authored Hands-on Time Series Analysis with Python and has reviewed 43+ technical books. Ashish’s expertise lies in data science, machine learning, deep learning, and MLOps on AWS, with proficiency in AWS SageMaker, AWS Generative AI and ML Services, AWS MLOps, and more. Notably, he has successfully designed and built AI ML project System architecture and built complex enterprise solutions with Red Hat Open Shift and AWS Infrastructure, adhering to the AWS Well-Architected Framework for operational excellence and security. Ashish’s passion for AI and ML is evident through his 30+ impactful talks on the subject.
There is an ever-growing need for deep learning experts across the globe and TensorFlow is a leading framework for building deep learning applications. To meet the growing demand for developers with the requisite skills to build deep learning applications across various domains, the TensorFlow Developer Certificate was established. This 5-hour, hands-on exam is designed to test a developer’s foundational knowledge in building, training, saving, and debugging models in computer vision, natural language processing, time series, sequences and predictions.
This book serves as a comprehensive guide in preparing you for this exam. You will begin by understanding the fundamentals of machine learning and the exam in itself. With each chapter, you will acquire new skills with hands-on coding examples and exercises in which you master the science and art of model building for image classification, natural language processing and time series forecasting.
By the end of this book, you will be well equipped with all the nuts and bolts to effectively ace this exam in one sitting.
This book is for students, data scientists, machine learning engineers and anyone who wants to master how to build deep learning models using TensorFlow and ace the TensorFlow Developer Certificate in the first attempt.
Chapter 1, Introduction to Machine Learning, cover, the fundamentals of machine learning, its types, the machine learning life cycle, and applications of machine learning. We will also drill down into what it takes to become a certified TensorFlow developer.
Chapter 2, Introduction to TensorFlow, examines the TensorFlow ecosystem after which we set up our work environment. Also, we will take a look at data representation then we will build our hello world model using TensorFlow. We will conclude this chapter by examining how to debug and resolve error messages we come across as we build models.
Chapter 3, Linear Regression with TensorFlow, examines how to build linear regression models using TensorFlow. Next, we will explore various evaluation metrics for regression models. We will take matters a step further by building a salary prediction model with TensorFlow and we will close this chapter by mastering how to save and load models.
Chapter 4, Classification with TensorFlow, examines what classification modeling in machine learning is, and discusses different types of classification problems you may encounter in machine learning. Also, we’ll examine the various methods of evaluating classification problems and look at how to choose the right classification metrics for your use case. We will close this chapter by looking at a classification problem where we will learn how to build, compile, train, make predictions, and evaluate classification models using TensorFlow.
Chapter 5, Image Classification With Neural Networks, covers the anatomy of neural networks. We’ll discuss concepts such as forward propagation, backward propagation, and gradient descent. We will also discuss the moving parts such as the input layer, hidden layers, output layers, activation functions, loss function, and optimizers. We will close this chapter by examining how to build an image classifier using a neural network with TensorFlow.
Chapter 6, Improving the Model, examines various methods of improving the performance of our model. We will discuss the importance of data-centric strategies such as data augmentation and look at various hyperparameters, their impact, and how we can tune them to improve the performance of our models.
Chapter 7, Image Classification with Convolutional Neural Networks, introduces convolutional neural networks (CNNs). We’ll see how CNNs change the game in image classification tasks by exploring its anatomy, exploring concepts like convolutions and pooling operations. We will examine the challenges developers face when working with real world images. We will close the chapter by seeing CNNs in action as we apply them to classifying weather image data.
Chapter 8, Handling Overfitting, examines overfitting in greater details. We will examine what it is and why it occurs in real-world use cases. We will then go a step further by exploring various ways to overcome overfitting such as dropout regularization, early stopping and L1 & L2 regularization. We will put these ideas to the test using the weather image dataset case study to help us cement our understanding of these concepts.
Chapter 9, Transfer Learning, introduces the concept of transfer learning and we will discuss where and how we can apply transfer learning. We will also examine some best practices around applying transfer learning in our workflow. To close this chapter, we will build a real-world image classifier using pretrained models from TensorFlow.
Chapter 10, Introduction to Natural Language Processing, introduces natural language processing. We will discuss challenges around working with text data, and how we can move from language to vector representations. We will cover foundational ideas around text preprocessing and data preparation techniques such as tokenization, padding, sequencing, and word embedding. We will step things up by examining how to visualize word embeddings using TensorFlow’s projector. To close this chapter, we will build a sentiment classifier using TensorFlow.
Chapter 11, NLP with TensorFlow, goes deeper into the challenges of modeling text data. We will introduce recurrent neural networks (RNNs) and their variants, long short-term memory (LSTM) and gated recurrent units (GRU). We’ll see how they are uniquely tailored for handling sequential data such as text and time series data. We will apply these models in building a text classifier. We will also see how to apply pretrained word embeddings in this chapter. To close this chapter, we will see how we can build a children’s story generator using LSTMs.
Chapter 12, Introduction to Time Series, Sequences and Predictions, introduces time series data and examines the unique nature of time series data, its core characteristics, types and application of time series data. We will discuss some of the challenges with modeling time series data and examine a number of solutions. We will see how to prepare time series data for forecasting using utilities in TensorFlow, and then we will apply both statistical methods and machine learning techniques to forecast sales data for a fictional super store.
Chapter 13, Time Series, Sequences and Prediction with TensorFlow, discusses how to use in-built and custom learning rate schedulers in TensorFlow, we will also see how to apply lambda layers. We will see how to build time series forecasting models using RNNs, LSTMs, CNNs and CNN-LSTM networks. We will round off this chapter and the book by working through a problem where we will collect realworld closing stock prices and build a forecasting model.
To get the most out of this book you need to be proficient in Python and need to have a desire to learn all things in machine learning. We’ll be using Google Colab in this book but you can use your preferred IDE with the following requirements:
Software/hardware covered in the book
Operating system requirements
Python 3.9.2
Windows, macOS, or Linux
tensorflow==2.13.0
numpy==1.24.3
pandas==2.0.3
Pillow==10.0.0
scipy==1.10.1
tensorflow-datasets==4.9.2
If you are using the digital version of this book, we advise you to type the code yourself or access the code from the book’s GitHub repository (a link is available in the next section). Doing so will help you avoid any potential errors related to the copying and pasting of code.
You can download the example code files for this book from GitHub at https://github.com/PacktPublishing/TensorFlow-Developer-Certificate-Guide. If there’s an update to the code, it will be updated in the GitHub repository.
We also have other code bundles from our rich catalog of books and videos available at https://github.com/PacktPublishing/. Check them out!
There are a number of text conventions used throughout this book.
Code in text: Indicates code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles. Here is an example: “This metadata information is stored in the infovariable ”
A block of code is set as follows:
import numpy as np from numpy importWhen we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:
(<tf.Tensor: shape=(2, 3), dtype=int64, numpy=array([[10, 11, 12], [ 3, 4, 5]])>, <tf.Tensor: shape=(2,), dtype=int64, numpy=array([13, 6])>)Bold: Indicates a new term, an important word, or words that you see onscreen. For instance, words in menus or dialog boxes appear in bold. Here is an example: “Convolutional neural networks (CNNs) are the go-to algorithms when it comes to image classification.”
Tips or important notes
Appear like this.
Feedback from our readers is always welcome.
General feedback: If you have questions about any aspect of this book, email us at [email protected] and mention the book title in the subject of your message.
Errata: Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you have found a mistake in this book, we would be grateful if you would report this to us. Please visit www.packtpub.com/support/errata and fill in the form.
Piracy: If you come across any illegal copies of our works in any form on the internet, we would be grateful if you would provide us with the location address or website name. Please contact us at [email protected] with a link to the material.
If you are interested in becoming an author: If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, please visit authors.packtpub.com.
Once you’ve read TensorFlow Developer Certificate Guide, we’d love to hear your thoughts! Please click here to go straight to the Amazon review page for this book and share your feedback.
Your review is important to us and the tech community and will help us make sure we’re delivering excellent quality content.
Thanks for purchasing this book!
Do you like to read on the go but are unable to carry your print books everywhere?
Is your eBook purchase not compatible with the device of your choice?
Don’t worry, now with every Packt book you get a DRM-free PDF version of that book at no cost.
Read anywhere, any place, on any device. Search, copy, and paste code from your favorite technical books directly into your application.
The perks don’t stop there, you can get exclusive access to discounts, newsletters, and great free content in your inbox daily
Follow these simple steps to get the benefits:
Scan the QR code or visit the link belowhttps://packt.link/free-ebook/978-1-80324-013-8
Submit your proof of purchaseThat’s it! We’ll send your free PDF and other benefits to your email directlyn this part of the book, you will learn the foundations of machine learning and deep learning required to succeed in this exam. You will learn to read data from different sources and in different formats. You will also learn how to build a regression and classification model, debug, save, load the model, and also make predictions with real world data.
This section comprises of the following chapters:
Chapter 1, Introduction to Machine LearningChapter 2, Introduction to TensorFlowChapter 3, Linear Regression with TensorFlowChapter 4, Classification with TensorFlowThere has never been a more exciting time to be a deep learning expert. With the advent of super-fast computers, open source algorithms, well-curated datasets, and affordable cloud services, deep learning experts are armed with the requisite skills to build amazing and impactful applications across all domains. Computer vision, natural language processing, and time series analysis are just a few of the areas where deep learning experts can make a real impact. Anyone with the right skills can build a groundbreaking application and perhaps become the next Elon Musk. For this to happen, adequate knowledge of deep learning frameworks such as TensorFlow is required.
The TensorFlow Developer Certificate aims to build a new generation of deep learning experts who are already in high demand across all fields. Hence, joining this club equips you with the required expertise to start your journey as a deep learning expert and also presents you with a certificate to show for your weeks, months, or years of hard work.
We will begin this chapter with a high-level introduction to machine learning (ML), after which we will examine the different types of ML approaches. Next, we will drill down into the ML life cycle and use cases (we will cover a few hands-on implementations in subsequent chapters). We conclude this chapter by introducing the TensorFlow Developer Certificate and examining the anatomy of the core components needed to ace the exam. By the end of this chapter, you should be able to clearly explain what ML is and have gained a foundational understanding of the ML life cycle. Also, after this chapter, you will be able to differentiate between different types of ML approaches and clearly understand what the TensorFlow Developer Certificate exam is all about.
In this chapter, we will cover the following topics:
What is ML?Types of ML algorithmsThe ML life cycleExploring ML use casesIntroducing the learning journeyML is a subfield of artificial intelligence (AI) in which computer systems learn patterns from data to perform specific tasks or make predictions on unseen data without being explicitly programmed. In 1959, Arthur Samuel defined ML as a “field of study that gives computers the ability to learn without being explicitly programmed to do so.” To give clarity to the definition given to us by Arthur Samuel, let us unpack it using a well-known use case of ML in the banking industry.
Imagine we work in the ML team of a Fortune 500 bank in the heart of London. We are saddled with the responsibility of automating the fraud detection process as the current manual process is too slow and costs the bank millions of pounds sterling, due to delays in the transaction processing time. Based on the preceding definition, we request historical data of previous transactions, containing both fraudulent and non-fraudulent transactions, after which we go through the ML life cycle (which we will cover shortly) and deploy our solution to prevent fraudulent activities.
In this example, we used historical data that provides us with the features (independent variables) needed to determine the outcome of the model, which is generally referred to as the target (dependent variable). In this scenario, the target is a fraudulent or non-fraudulent transaction, as shown in Figure 1.1.
Figure 1.1 – A flowchart showing the features and the target in our data
In the preceding scenario, we were able to train a model with historical data made up of features and the target to generate rules that are used to make predictions on unseen data. This is an example of what ML is all about – the ability to empower computers to make decisions without explicit programming. In classic programming, as shown in Figure 1.2, we feed in the data and some hardcoded rules – for example, the volume of a daily transaction to determine whether it is fraudulent or not. If a customer goes above this daily limit, the customer’s account gets flagged, and a human moderator will intervene to decide whether the transaction was fraudulent or not.
Figure 1.2 – A traditional programming approach
This approach will soon leave the bank overwhelmed with unhappy customers constantly complaining about delayed transactions, while fraudsters and money launderers will evade the system by simply limiting their transactions within the daily permissible limits defined by the bank. With every new attribute, we would need to update the rules. This approach quickly becomes impractical, as there will always be something new to update to make the system tick. Like a house of cards, the system will eventually fall apart, as such a complex problem with continuously varying attributes across millions of daily transactions may be near impossible to explicitly program.
Thankfully, we do not need to hardcode anything. We can use ML to build a model that can learn to identify patterns of fraudulent transactions from historical data, based on a set of input features in it. We train our model using labeled historical data of past transactions that contain both fraudulent and non-fraudulent transactions. This allows our model to develop rules based on the data, as shown in Figure 1.3, which can be applied in the future to detect fraudulent transactions.
Figure 1.3 – An ML approach
The rules generated by examining the data are used by the model to make new predictions to curb fraudulent transactions. This paradigm shift differs from traditional programming where applications are built using well-defined rules. In ML-powered applications, such as our fraud detection system, the model learns to recognize patterns and create rules from the training data; it then uses these rules to make predictions on new data to efficiently flag fraudulent transactions, as shown in Figure 1.4:
Figure 1.4 – An ML model uses rules to make predictions on unseen data
In the example we just examined, we can see from Figure 1.1 that our training data is usually structured in a tabular form, made up of numerical values such as transaction amount and frequency of transactions, as well as categorical variables such as location and payment type. In this type of data representation, we can easily identify both the features and the target. However, what about textual data from social media, images from our smartphones, video from streaming movies, and so on, as illustrated in Figure 1.5? How do we approach these types of problems where the data is unstructured? Thankfully, we have a solution, which is called deep learning.
Figure 1.5 – An illustration of structured and unstructured data types
Deep learning is a subset of ML that mimics the human brain by using complex hierarchical models that are composed of multiple processing layers. The buzz around deep learning lies around the state-of-the-art performance recorded by deep learning algorithms over the years across many real-world applications, such as object detection, image classification, and speech recognition, as deep learning algorithms can model complex relationships in data. In Sections 2 and 3, we will discuss deep learning in greater detail and see it in action for image and text applications, respectively. For now, let us probe further into the world of ML by looking at the types of ML algorithms.
In the last section, we looked at what ML is, and we examined a use case where we had labeled data. In this section, we will look at the four main types of ML approaches to give us a base understanding of what each type does, and where and how they can be applied. The four types of ML algorithms are as follows:
Supervised learningUnsupervised learningSemi-supervised learningReinforcement learningLet’s examine the four types of ML methods, which will serve as a building block for later chapters.
In supervised learning, an ML model is trained using data made of features and a target. This enables the model to learn the underlying relationship in the data. After training, the model can use its newfound knowledge to make predictions on unseen data. For example, say you want to buy a house. You would consider factors such as the location of the house, the number of rooms, the number of bathrooms, whether it has a garden, and the type of property; these factors you would consider as the features, while the price of the house is the target. Perhaps after the TensorFlow exam, you can roll up your sleeves, scrape some housing data, and train a model to predict house prices based on these features. You can use your house prediction model to compare prices on real estate websites to close a good deal for yourself.
There are two types of supervised learning – regression and classification. In a regression task, the label is a numeric value, just like the example we gave previously in which the target is the predicted price of the house. Conversely, in a classification task, the label is a category, just like the fraud example we discussed previously, in which the goal was to detect whether a transaction was fraudulent or not fraudulent. In a classification task, the model will learn to categorize the target as classes.
When dealing with a classification task made up of two classes (for example, fraudulent and non-fraudulent transactions), it is referred to as binary classification. When there are more than two categories (for example, the classification of different car brands), it is referred to as multi-class classification.
Figure 1.6: An example of multi-label classification, where the model identifies multiple subjects within an image
Multi-label classification is another type of classification, and it is used for image tagging in social media applications such as Facebook and Instagram. Unlike binary and multi-class classification tasks in which we have one target per instance, in multi-label classification our model identifies multiple targets for each instance, as shown in Figure 1.6, where our model identifies a girl, a dog, a boy, and a cat in the given photo.
Unsupervised learning is the opposite of supervised learning. In this case, there is no labeled data. The model will have to figure things out by itself. Here, an unsupervised learning algorithm is provided with data, and we expect it to extract meaningful insights from the unlabeled data, by identifying patterns within the data without relying on predefined targets – for example, an image you work on for a large retail store that aims to segment its customers for marketing purposes. You are given data containing the demographics and spending habits of the store’s customers. By employing an unsupervised ML model, you successfully cluster customers with similar characteristics into distinct customer segments. The marketing team can now create a tailored campaign targeted at each of the customer segments identified by the model, potentially leading to a higher conversion rate from the campaign.
Semi-supervised learning is a combination of supervised and unsupervised learning. In this case, there is some data with labels (i.e., it has both features and a target) and the rest is without labels. In such scenarios, the unlabeled data is usually the dominant group. In this case, we can apply a combination of unsupervised and supervised learning methods to generate optimal results, especially when the cost implication and time required to manually label the data may not be practical. Here, the model takes advantage of the available label data to learn the underlying relationships, which it then applies to the unlabeled data.
Imagine you work for a big corporation that collects a large volume of documents that we need to classify and send to the appropriate department (i.e, finance, marketing, and sales) for effective document management, and only a small number of the documents are labeled. Here, we apply semi-supervised learning, train the model on the labeled document, and apply the learned patterns to classify the remaining unlabeled documents.
In reinforcement learning, unlike supervised learning, the model does not learn from training data. Instead, it learns from its interactions within an environment; it gets rewarded for making the right decisions and punished for making wrong choices. It is a trial-and-error learning approach in which the model learns from its past experience to make better decisions in the future. The model aims to maximize reward. Reinforcement learning is applied in self-driving cars, robotics, trading and finance, question answering, and text summarization, among other exciting use cases.
Now that we can clearly differentiate between the different types of ML approaches, we can look into what the core components of an ML life cycle are and what steps we should take, from the birth of a project to its application by end users. Let us take a look at the ML life cycle.
Before embarking on any ML project, we must take into account some key components that can determine whether our project will be successful or not. And this is important because as data professionals who want to build and implement successful ML projects, we need to understand how the ML life cycle works. The ML life cycle is a sensible framework to implement an ML project, as shown in Figure 1.7:
Figure 1.7 – The ML life cycle
Let’s look at each of these in detail.
Before unleashing state-of-the-art models on any problem, it is imperative you take time to sit with stakeholders to clearly understand the business objectives or the pain points to be resolved, as without clarity, the entire process will almost definitely fail. It is always important to keep in mind that the goal of the entire process is not to test a new breakthrough model you have been itching to try out but to solve a pain point, or create value for your company.
Once we understand the problem, we can categorize the problem as either a supervised or unsupervised learning task. This phase of an ML life cycle is all about asking the right questions. We need to sit with the concerned team to determine what the key metrics that would define the project as a success are. What resources are required in terms of budget, manpower, compute, and the project timeline? Do we have the domain understanding or do we need an expert’s input into defining and understanding the underlying factors and goals that will define the project’s success? These are some of the questions we should ask as data professionals before we embark on a project.
For the exam, we will need to understand the requirements of each question before we tackle them. We will discuss a lot more about the exam before we conclude this chapter.
When all the requirements are detailed, the next step is to collect the data required for the project. In this phase, we would first determine what type of data we will collect and where we will collect it from. Before we embark on anything, we need to ask ourselves whether the data is relevant – for example, if we collect historical car data from 1980, would we be able to predict the price of a car in 2022? Would data be made available by stakeholders, or would we be collecting it from a database, Internet of Things (IoT) devices, or via web scraping? Would there be any need for the collection of secondary data for the task at hand? Also, we would need to establish whether the data will be collected all at once or whether it will be a continuous process of data collection. Once we have collected the data needed for the project, we would then examine the data to get an understanding of it.
Next, we would examine the data to see whether the data collected is in the right format. For example, if you collect car sales data from multiple sources, one source may calculate a car’s mileage in kilometers per hour and another source could use miles per hour. Also, there could be missing values in some of the features, and we might also encounter duplicates, outliers, and irrelevant features in the data we collected. During this phase, we would carry out data exploration to gain insights into the data, and data preprocessing to handle various issues such as formatting problems, missing values, duplicates, removal of irrelevant features, and handling outliers, imbalanced data, and categorical features.
Now that we have a good understanding of the business needs, we have decided on the type of ML problem that we will address, and we also have good-quality data after completing our preprocessing step. We will split our data into a training split and keep a small subset of the test to evaluate the model’s performance. We will train our model to understand the relationship between the features and the target variable using our training set. For example, we could train our fraud detection model on historical data provided by the bank and test it out with our hold out (test set) to evaluate our model’s performance before deploying it for use. We go through an iterative process of fine-tuning our model hyperparameters until we arrive at our optimal model.
Defining whether the modeling process is a success or not is tied to the business objective, since achieving a high accuracy of 90 percent would still leave room for a 10 percent error, which could be decisive in high-stake domains such as healthcare. Imagine you deploy a model for early-stage cancer detection with an accuracy of 90 percent, which means the model would likely fail once for every 10 people; in 100 tries, it could fail about 10 times, and it could misclassify someone with cancer as healthy. This could lead to the individual not only failing to seek medical advice but also to an untimely demise. Your company could get sued and the blame would fall in your lap. To avoid situations like this, we need to understand what metrics are important for our project and what we should be less strict with. It is also important to address factors such as class imbalance, model interpretability, and ethical implications.
There are various metrics that are used to evaluate a model, and the type of evaluation depends on the type of problem we will handle. We will discuss regression metrics in Chapter 3, Linear Regression with TensorFlow, and classification metrics in Chapter 4, Classification with TensorFlow,.
We are not ready for deployment yet. Remember the 10 percent data that could tank our project? We will address that here. We perform an error analysis to identify the misclassified labels to identify why the model missed them. Do we have enough representative samples of these misclassified labels in our training data? We would have to determine whether we need to collect more data to capture these cases where the model failed. Can we generate synthetic data to capture the misclassified labels? Or was the misclassified data down to the wrong labeling?
Wrongly labeled data can hamper the performance of a model, as it will learn incorrect relationships between the features and target, resulting in poor performance on unseen data, making the model unreliable and the entire process a waste of resources and time. Once we resolve these questions and ensure accurate labels, we need to retrain and reevaluate our model. These steps are continuous until the business objective is achieved, and then we can proceed to deploy our model.
After resolving the issues identified in the error analysis step, we can now deploy our model to production. There are various methods of deployment available. We could deploy our model as a web service, on the cloud, or on edge devices. Model deployment can be challenging as well as exciting because the entire point of building and training a model is to allow end users to apply it to solve a pain point. Once we deploy our model, we also monitor the model to ensure that the overall objectives of the business are continually achieved, and even the best-performing models can begin to underperform over time due to concept drift and data drift. Hence, after deploying our model, we cannot retire to some island. We need to continuously monitor our model and retrain the model when needed in order to ensure it continues to perform optimally.
We have now gone through the full length of the ML life cycle at a high level. Of course, there is a lot more that we can talk about in greater depth, but this is out of the scope of this exam. Hence, we will now switch our focus to looking at a number of exciting use cases where ML can be applied.
Beyond the car price prediction and fraud detection use cases, let’s look at some exciting applications of ML here. Perhaps it will get you fired up for both the exams and inspire you to build something spectacular in your ML journey.
HearAngel uses AI to automatically prevent hearing loss for headphone users by tracking users’ exposure to unhealthy levels of sounds from the headphones. Insitro uses knowledge of ML and biology for drug discovery and development. Other use cases of ML in healthcare include smart record keeping, data collection, disease outbreak forecasting, personalized medicine, and disease identification.
ML engineers are revolutionizing the retail industry by deploying models to enhance customer experience and improve profitability. This is achieved by optimizing assortment planning, predicting customer behavior, the provision of virtual assistants, inventory optimization, tracking customers’ sentiments, price optimization, product recommendation, and customer segmentation, among other use cases. In the retail industry, ML engineers provide value by automating cumbersome manual processes.
The entertainment industry currently applies ML/AI in automatic script and lyric generation. Yes, currently there are movie script-writing ML models. One such movie is a short science fiction movie called Sunspring (https://arstechnica.com/gaming/2021/05/an-ai-wrote-this-movie-and-its-strangely-moving/). Also, ML/AI is used for automatic caption generation, augmented reality, game development, target marketing, sentiment analysis, movie recommendation, and sales forecasting, among others. So, if you plan to carve a niche in this industry as an ML engineer, there is a lot you can do, and surely you can also come up with some new ideas.
Readrly utilizes deep learning techniques to create personalized children’s stories, enhancing the learning experience for young readers. By tailoring stories to each child’s interests and skill level, Readrly supports children’s reading development in a fun and engaging way.
There are numerous use cases of ML in agriculture. ML/AI can be used for price forecasting, disease detection, weather prediction, yield mapping, soil and crop health monitoring, and precision farming, among others.
Here, we covered some use cases of ML. However, the exciting part is that, as an ML/DL engineer, you will be able to apply your knowledge to any industry as long as data is available. And that is the awesomeness of being an ML engineer – there are no restrictions. We have covered a lot already in this chapter; however, we have one more section to go, and it is a very important one, as it centers on the exam itself. Let’s jump in.
The TensorFlow Developer Certificate exam was designed and developed by Google to assess data professionals’ expertise in model building and training deep learning models with TensorFlow. The exams enable data professionals to showcase their skills in solving real-world problems with ML/DL, as shown in Figure 1.8.
Figure 1.8 – The goal of the exam
Let’s dig deeper into why you should take this exam.
One of the most compelling reasons why you should take the TensorFlow Developer Certificate is that it can help you get a job. The global AI market is expected to grow exponentially, reaching $2 trillion by 2030 according to a report by Statista (https://www.statista.com/statistics/1365145/artificial-intelligence-market-size/#:~:text=The%20market%20for%20artificial%20intelligence,nearly%20two%20trillion%20U.S.%20dollars).
This rapid growth is being driven by continued advancements in areas such as autonomous vehicles, image recognition, and natural language processing, powering a new wave of applications across a wide range of industries. This growth is expected to create an increased demand for deep learning specialists who can build cutting-edge ML solutions.
In light of this development, recruiters and hiring managers are on the lookout for skilled candidates who can build deep learning models with TensorFlow, and this certificate can help you stand out from the crowd. To further accelerate your job-hunting, Google has put together TensorFlow Certificate Network, which is an online database of certified TensorFlow developers across the globe, as shown in Figure 1.9. Hiring managers can easily find suitable candidates to build their machine learning and deep learning solutions using a range of filters, such as location and years of experience, as well as verifying a candidate based on their name.
Figure 1.9 – A map display of TensorFlow-certified developers
In addition to helping you get a first job, the TensorFlow Developer Certificate can also help you advance your career. If you’re already working with TensorFlow, the certificate can help you demonstrate your expertise to your employer. This can lead to promotions and raises.
Now that we have looked at some of the reasons why you should take the exam, the next logical step is to look at what the exam is all about. Let us do that.
If you’re planning on becoming a certified TensorFlow developer, there are a few things you’ll need to know. Here’s a quick rundown of what you need to know to ace the TensorFlow Developer Certificate exam:
TensorFlow developer skillsBuilding and training neural network models using TensorFlow 2.xImage classificationNatural language processing (NLP)Time series, sequences, and predictionsYou can find the complete exam details here: https://www.tensorflow.org/static/extras/cert/TF_Certificate_Candidate_Handbook.pdf. However, this book covers each section of the exam in detail to help ensure success. The exam costs $100, but there is an option to apply for a stipend that, if approved, will allow you to only pay half the exam fee. The stipend must be used within 90 days of receiving it and is only valid for one attempt. To apply for the stipend, you must provide information about yourself, why you need the stipend, and your portfolio projects with TensorFlow if you have any. You can find more information about how to access the TensorFlow Education Stipend using this link: https://www.tensorflow.org/static/extras/cert/TF_Education_Stipend.pdf.
We have now covered what and why. Now, let us look at how you can ace the exam.
If you’re looking to become a certified TensorFlow developer, there are a few things you should know. First, you should be proficient in Python. Second, you’ll need to have a strong understanding of ML concepts and be able to use TensorFlow to build and train deep learning models with TensorFlow. If you’re not already familiar with Python programming, then Modern Python Cookbook – Second Edition by Steven F Lott is a good place to start.
Here are some tips to help you ace the TensorFlow Developer Certificate exam:
Review the course material: Before taking the exam, be sure to review the materials for every topic in the TensorFlow candidate handbook in detail. Pay special attention to building and training models, since the exam is hands-on.Model building: In addition to reviewing the course material, it’s also important to get some hands-on experience with TensorFlow. Experiment with building models, covering each section of the exam requirement. This book will get you started with the core fundamentals of ML and walk you through each section of the exam in a hands-on manner, ensuring that you can comfortably build and train all sorts of models with TensorFlow – from simple linear models to complex neural networks.Understand the exam format: The exam is unlike many other exams. It is a five-hour coding exam with questions covering each section of the exam that we outlined. You will be given a task and asked to write code to solve it in PyCharm. So, you will need to spend some time mastering how to build, train, and save models in PyCharm before the exams. The exam is an open-book one, so you are allowed to use any resource you want during the exam.Practice, practice, practice: One of the best ways to prepare for the exam is to practice solving questions. You will find lots of hands-on practice questions in every chapter of this book, along with code files in the book’s GitHub repository. Additionally, you will find lots of datasets on the TensorFlow website and Kaggle.Once you’ve completed this book, you should be ready to take the TensorFlow Developer Certificate exam.
Depending on your experience, you may need more or less time to prepare for the exam. If you are familiar with TensorFlow already, with hands-on model-building skills, you may take between three weeks to two months to prepare for the exam. However, if you are completely new to TensorFlow, it is advisable to look at around six months to thoroughly prepare for this exam, as stipulated on the exam website. However, these rules are not cast in stone. Everyone is different, so go at your own pace.
After you sign up for the exam, you can take it within a six-month period. It is okay to set a target day for your exams early enough. The exam takes place in PyCharm, so you will need to take a few days or weeks to get used to PyCharm (if you’re not familiar with it) before the exam day. Here is an excellent video tutorial by Jeff Henton to help you set up your PyCharm environment: https://www.youtube.com/watch?v=zRY5lx-So-c. Ensure you install the stipulated version of PyCharm. You can also learn more about setting up the exam environment using this link: https://www.tensorflow.org/static/extras/cert/Setting_Up_TF_Developer_Certificate_Exam.pdf.
Before the exam, it helps to have a clearly planned study routine in which you can cover the outlined syllabus for the exam. This book will help you on this journey, so you should pay attention to the next chapters, as we will start coding and tackling the core components, which make up the exam henceforth. On exam day, I would advise you to find a quiet, comfortable space to take this exam. Ensure you are well rested and not going in exhausted, as the exam is five hours long. Also, try out your PyCharm and internet connectivity. Don’t panic, and read the questions thoroughly to have a clear understanding of what is required of you. Start from questions 1 to 5. Since the questions get more difficult, it is better to get the easy ones out of the way quickly and tackle the more difficult ones afterward.
However, you should pace yourself correctly. Your saved model will be graded each time you submit it, and you are allowed to submit as many times as you want within the stipulated 5-hour time frame until you achieve an optimal result. You can also run your model in Colab if this enables you to work faster, especially if you have a model running in PyCharm. Colab provides you with free GPU access to train your model. The exam will be graded only in PyCharm, so bear this in mind. Ensure you save the model you train in Colab, and move it to the directory where you are stipulated to save the model for the exam.
If you need help, you can use Stack Overflow. You can also look through the code we use in this book, or any other material you use to prepare for your exam. However, if a question proves too difficult, move on to other questions. When you are done, you can return to the difficult one and work your way through it to avoid losing all your time on a difficult question. Also, you are allowed to submit multiple times, so work on improving your models until you attain optimal performance.
The exam ends after five hours exactly, but you can submit it before that. After which, you will receive a congratulatory email if you have passed. After passing this exam, you will now be a member of the Google TensorFlow Developer community, opening more doors of opportunity for yourself. Assuming you pass (and I hope you do), you will get your certificate in about a week, which will look like Figure 1.10, and you will be added to the Google TensorFlow community in about two weeks. The certificate is valid for a period of three years.
Figure 1.10 – TensorFlow Developer Certificate
Now, you know the topics, the time frame, the cost, how to prepare, what to do on exam day, and what to expect after the exam. With this, we have come to the end of this chapter. We have covered a lot of theory in this chapter, which will serve as the basis for the work we will do together in the upcoming chapters.
This chapter provided an overview of ML, deep learning, and the types of ML approaches. It also covered the ML life cycle and various ML use cases across different domains. We looked at a high-level overview of the TensorFlow Developer Certificate, along with information on the components of the exam and how to prepare for it. At the end of this chapter, you should have a good foundational understanding of what ML is and its types. You should now be able to determine which problems are ML-based problems and those that require classic programming. You should also be able to unpack ML problems into different types and be familiar with what it takes to prepare for the TensorFlow Developer Certificate exam by Google.
In the next chapter, we will look at what TensorFlow is, set up our environment, and start coding our way to the end of this book.
Let’s test what we learned in this chapter:
What is ML?What is deep learning?What are the types of ML?What are the steps in the ML life cycle?What is the TensorFlow Developer Certificate about?What are the core areas of the exam?To learn more, you can check out the following resources:
TensorFlow Developer Certificate overview: https://www.tensorflow.org/certificateHands-On Machine Learning with scikit-learn and Scientific Python: Toolkits by Amr, T., Packt PublishingDeep Learning: Methods and Applications by Li Deng, and Dong Yu: https://doi.org/10.1561/2000000039Movie written by algorithm turns out to be hilarious and intense: https://arstechnica.com/gaming/2021/05/an-ai-wrote-this-movie-and-its-strangely-moving/.Python Machine Learning – Third Edition by Sebastian Raschka and Vahid Mirjalili