Search icon CANCEL
Subscription
0
Cart icon
Cart
Close icon
You have no products in your basket yet
Save more on your purchases!
Savings automatically calculated. No voucher code required
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Hands-On Transfer Learning with Python

You're reading from  Hands-On Transfer Learning with Python

Product type Book
Published in Aug 2018
Publisher Packt
ISBN-13 9781788831307
Pages 438 pages
Edition 1st Edition
Languages
Authors (4):
Dipanjan Sarkar Dipanjan Sarkar
Profile icon Dipanjan Sarkar
Nitin Panwar Nitin Panwar
Profile icon Nitin Panwar
Raghav Bali Raghav Bali
Profile icon Raghav Bali
Tamoghna Ghosh Tamoghna Ghosh
Profile icon Tamoghna Ghosh
View More author details
Toc

Table of Contents (14) Chapters close

Preface 1. Machine Learning Fundamentals 2. Deep Learning Essentials 3. Understanding Deep Learning Architectures 4. Transfer Learning Fundamentals 5. Unleashing the Power of Transfer Learning 6. Image Recognition and Classification 7. Text Document Categorization 8. Audio Event Identification and Classification 9. DeepDream 10. Style Transfer 11. Automated Image Caption Generator 12. Image Colorization 13. Other Books You May Enjoy

Building CNN models from scratch

Let's start building our image categorization classifier. Our approach will be to build models on our training dataset and validate it on our validation dataset. In the end, we will test the performance of all our models on the test dataset. Before we jump into modeling, let's load and prepare our datasets. To start with, we load up some basic dependencies:

import glob 
import numpy as np 
import matplotlib.pyplot as plt 
from keras.preprocessing.image import ImageDataGenerator, load_img, img_to_array, array_to_img 
 
%matplotlib inline 

Let's now load our datasets, using the following code snippet:

IMG_DIM = (150, 150) 
 
train_files = glob.glob('training_data/*') 
train_imgs = [img_to_array(load_img(img, target_size=IMG_DIM)) for img  
in train_files] train_imgs = np.array(train_imgs) train_labels = ...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €14.99/month. Cancel anytime