Sequential Model - TensorFlow Essentials #1
Key Takeaways
This video introduces the sequential model building approach in TensorFlow 2, covering the basics of the sequential model, how to add layers using the add method, and how to define a model using a single initialization function. The video uses TensorFlow's Keras API to build a simple neural network model with two layers: a densely connected neural network layer and an output layer with a softmax activation function.
Full Transcript
hi welcome to this introduction to the sequential model in tensorflow so we're just going to go ahead and start a new notebook here now i want to do is import tensorflow now the sequential model is one of two different approaches that we can use for building our models in tensorflow those are the functional api and then the sequential model that we're going to go through here so the sequential model is better for simple sequential stacks of layers where each layer has just one input and just one output so if our model looks something like this then the sequential approach is probably better so we access the sequential model using tf.keras.sequential so it looks like this and then that initializes the sequential model and then there are two methods for adding layers with this model the first of those which i'm going to show you is using the add method so all we do is take model add and then we add our layer here so one of the layers that we'll be using quite a lot is a densely connected neural network layer so we just write tf keras layers dense and then we're going to add in 32 units here and our input shape will be 10 units so here we have 10 inputs and they are each connected to 32 units within our dense layer here and they will use a rayleigh activation function which is a rectified linear unit now you don't need to know all this right now but what i do want you to focus on is the shape that we are producing so if we go over to here this is the shape of the network that we're building so we have 10 inputs so that was represented by the input shape and then we have 32 neurons in the middle so 32 units if you look because it's a density connected neural network every single one of these is connected to every single one so all of our 10 inputs are connected to this unit here this one this one this one and so on and then in our output i want to put two units so we'll go ahead and do that now so if we want to add another layer we just call me add again so we can run that okay sorry this is input shape and if we want to add another layer all we do is model add again now we only need to define the input shape in our first layer with the sequential model otherwise we don't need to define it because it will assume that our input shape matches the shape of the previous layer which in this case is 32 so we don't need to do anything there so we just put two and then we add in our activation now because this is the output layer and we have more than one output we will be using the softmax activation so in the output layer you will usually have either sigmoid or softmax if you just have one output so if your output is just one value between zero and one you use sigmoid if you have multiple outputs so we have two units here that means our output can look something like this and what we will want to do is take the maximum value as the answer so in this case it would be indexed at zero so the output label would be zero and when we're doing that we want to use the softmax activation function so we can execute that and then we can print out our model with the model summary and here we can see okay we have a sequential model and it has two layers so this doesn't include the input layer so our input layer is actually 10 units and then it goes into the actual model which is 32 units this is our hidden layer and then our output layer is two units at the end there and we see that there are a total of 418 parameters and all those trainable so that those are the number of numbers that the model will adjust in order to learn patterns within the training data okay so that is our first option for building a sequential model but we also have another way of building it so rather than using the add method we can actually define our model all within the single initialization function like this we just add a list and then we take what we had here just the layer and add it in and you just add each layer as a item within the list and then we just execute that print the model summary and we have the exact same model so that is everything on the sequential model i hope you've enjoyed and i hope it's been useful so thank you for watching and i will see you again soon bye
Original Description
Learn how to use the sequential model building approach in TensorFlow 2.
🤖 70% Discount on the NLP With Transformers in Python course:
https://bit.ly/3DFvvY5
Background thumbnail by Aryan Dhiman on Unsplash
https://unsplash.com/@mylifeasaryan_?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText
Watch on YouTube ↗
(saves to browser)
Sign in to unlock AI tutor explanation · ⚡30
Playlist
Uploads from James Briggs · James Briggs · 10 of 60
1
2
3
4
5
6
7
8
9
▶
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
Stoic Philosophy Text Generation with TensorFlow
James Briggs
How to Build TensorFlow Pipelines with tf.data.Dataset
James Briggs
Every New Feature in Python 3.10.0a2
James Briggs
How-to Build a Transformer for Language Classification in TensorFlow
James Briggs
How-to use the Kaggle API in Python
James Briggs
Language Generation with OpenAI's GPT-2 in Python
James Briggs
Text Summarization with Google AI's T5 in Python
James Briggs
How-to do Sentiment Analysis with Flair in Python
James Briggs
Python Environment Setup for Machine Learning
James Briggs
Sequential Model - TensorFlow Essentials #1
James Briggs
Functional API - TensorFlow Essentials #2
James Briggs
Training Parameters - TensorFlow Essentials #3
James Briggs
Input Data Pipelines - TensorFlow Essentials #4
James Briggs
6 of Python's Newest and Best Features (3.7-3.9)
James Briggs
Novice to Advanced RegEx in Less-than 30 Minutes + Python
James Briggs
Building a PlotLy $GME Chart in Python
James Briggs
How-to Use The Reddit API in Python
James Briggs
How to Build Custom Q&A Transformer Models in Python
James Briggs
How to Build Q&A Models in Python (Transformers)
James Briggs
How-to Decode Outputs From NLP Models (Python)
James Briggs
Identify Stocks on Reddit with SpaCy (NER in Python)
James Briggs
Sentiment Analysis on ANY Length of Text With Transformers (Python)
James Briggs
Unicode Normalization for NLP in Python
James Briggs
The NEW Match-Case Statement in Python 3.10
James Briggs
Multi-Class Language Classification With BERT in TensorFlow
James Briggs
How to Build Python Packages for Pip
James Briggs
How-to Structure a Q&A ML App
James Briggs
How to Index Q&A Data With Haystack and Elasticsearch
James Briggs
Q&A Document Retrieval With DPR
James Briggs
How to Use Type Annotations in Python
James Briggs
Extractive Q&A With Haystack and FastAPI in Python
James Briggs
Sentence Similarity With Sentence-Transformers in Python
James Briggs
Sentence Similarity With Transformers and PyTorch (Python)
James Briggs
NER With Transformers and spaCy (Python)
James Briggs
Training BERT #1 - Masked-Language Modeling (MLM)
James Briggs
Training BERT #2 - Train With Masked-Language Modeling (MLM)
James Briggs
Training BERT #3 - Next Sentence Prediction (NSP)
James Briggs
Training BERT #4 - Train With Next Sentence Prediction (NSP)
James Briggs
FREE 11 Hour NLP Transformers Course (Next 3 Days Only)
James Briggs
New Features in Python 3.10
James Briggs
Training BERT #5 - Training With BertForPretraining
James Briggs
How-to Use HuggingFace's Datasets - Transformers From Scratch #1
James Briggs
Build a Custom Transformer Tokenizer - Transformers From Scratch #2
James Briggs
3 Traditional Methods for Similarity Search (Jaccard, w-shingling, Levenshtein)
James Briggs
3 Vector-based Methods for Similarity Search (TF-IDF, BM25, SBERT)
James Briggs
Building MLM Training Input Pipeline - Transformers From Scratch #3
James Briggs
Training and Testing an Italian BERT - Transformers From Scratch #4
James Briggs
Faiss - Introduction to Similarity Search
James Briggs
Angular App Setup With Material - Stoic Q&A #5
James Briggs
Why are there so many Tokenization methods in HF Transformers?
James Briggs
Choosing Indexes for Similarity Search (Faiss in Python)
James Briggs
Locality Sensitive Hashing (LSH) for Search with Shingling + MinHashing (Python)
James Briggs
How LSH Random Projection works in search (+Python)
James Briggs
IndexLSH for Fast Similarity Search in Faiss
James Briggs
Faiss - Vector Compression with PQ and IVFPQ (in Python)
James Briggs
Product Quantization for Vector Similarity Search (+ Python)
James Briggs
How to Build a Bert WordPiece Tokenizer in Python and HuggingFace
James Briggs
Metadata Filtering for Vector Search + Latest Filter Tech
James Briggs
Build NLP Pipelines with HuggingFace Datasets
James Briggs
Composite Indexes and the Faiss Index Factory
James Briggs
More on: LLM Engineering
View skill →Related Reads
📰
📰
📰
📰
When Claude starts hallucinating, kill the session
Dev.to · Alex Tong
Why LLM-Era AI Systems Break Every Rule You Learned About ML in Production
Medium · Machine Learning
Why LLM-Era AI Systems Break Every Rule You Learned About ML in Production
Medium · LLM
Why LLM-Era AI Systems Break Every Rule You Learned About ML in Production
Medium · ChatGPT
🎓
Tutor Explanation
DeepCamp AI