Learn how generative AI works by building your very own models that can write coherent text, create realistic images, and even make lifelike music.
Learn Generative AI with PyTorch teaches the underlying mechanics of generative AI by building working AI models from scratch. Throughout, you’ll use the intuitive PyTorch framework that’s instantly familiar to anyone who’s worked with Python data tools. Along the way, you’ll master the fundamentals of General Adversarial Networks (GANs), Transformers, Large Language Models (LLMs), variational autoencoders, diffusion models, LangChain, and more!
In Learn Generative AI with PyTorch you’ll build these amazing models:
• A simple English-to-French translator
• A text-generating model as powerful as GPT-2
• A diffusion model that produces realistic flower images
• Music generators using GANs and Transformers
• An image style transfer model
• A zero-shot know-it-all agent
The generative AI projects you create use the same underlying techniques and technologies as full-scale models like GPT-4 and Stable Diffusion. You don’t need to be a machine learning expert—you can get started with just some basic Python programming skills.
Purchase of the print book includes a free eBook in PDF and ePub formats from Manning Publications.
About the technology
Transformers, Generative Adversarial Networks (GANs), diffusion models, LLMs, and other powerful deep learning patterns have radically changed the way we manipulate text, images, and sound. Generative AI may seem like magic at first, but with a little Python, the PyTorch framework, and some practice, you can build interesting and useful models that will train and run on your laptop. This book shows you how.
About the book
Learn Generative AI with PyTorch introduces the underlying mechanics of generative AI by helping you build your own working AI models. You’ll begin by creating simple images using a GAN, and then progress to writing a language translation transformer line-by-line. As you work through the fun and fascinating projects, you’ll train models to create anime images, write like Hemingway, make music like Mozart, and more. You just need Python and a few machine learning basics to get started. You’ll learn the rest as you go!
About the author
Mark Liu is the founding director of the Master of Science in Finance program at the University of Kentucky.
The technical editor on this book was Emmanuel Maggiori.
Table of Contents
Part 1
1 What is generative AI and why PyTorch?
2 Deep learning with PyTorch
3 Generative adversarial networks: Shape and number generation
Part 2
4 Image generation with generative adversarial networks
5 Selecting characteristics in generated images
6 CycleGAN: Converting blond hair to black hair
7 Image generation with variational autoencoders
Part 3
8 Text generation with recurrent neural networks
9 A line-by-line implementation of attention and Transformer
10 Training a Transformer to translate English to French
11 Building a generative pretrained Transformer from scratch
12 Training a Transformer to generate text
Part 4
13 Music generation with MuseGAN
14 Building and training a music Transformer
15 Diffusion models and text-to-image Transformers
16 Pretrained large language models and the LangChain library
Appendixes
A Installing Python, Jupyter Notebook, and PyTorch
B Minimally qualified readers and deep learning basics
EbookLicense
End-User Warranty And License Agreement
1. Grant Of License
Manning Has Authorized The Download By You Of An UnrestrictedNumber Of Copies Of The Electronic Book (Ebook) In Any Of The AvailableFormats. Manning Grants You A Nonexclusive, Nontransferable License To Use TheEbook According To The Terms And Conditions Herein. This License AgreementPermits You To Install The Ebook On Any And All Your Devices For Your PersonalUse Only.
2. Restrictions
You Shall Not: (1) Share, Resell, Rent, Assign, Timeshare,Distribute, Or Transfer All Or Part Of The Ebook Or Any Rights GrantedHereunder To Any Other Person; (2) Duplicate The Ebook, Except For A SingleBackup Or Archival Copy; (3) Remove Any Proprietary Notices, Labels, Or MarksFrom The Ebook; (4) Transfer Or Sublicense Title To The Ebook To Any OtherParty.
3. Intellectual Property Protection
The Ebook Is Owned By Manning And Is Protected By United StatesAnd International Copyright And Other Intellectual Property Laws. ManningReserves All Rights In The Ebook Not Expressly Granted Herein. This License AndYour Right To Use The Ebook Terminate Automatically If You Violate Any Part OfThis Agreement. In The Event Of Termination, You Must Remove The Original AndAny Copies Of The Ebook From All Your Devices.
4. Source Code Supplementary Material
Any Source Code Files Provided As A Supplement To The Book AreFreely Available To The Public For Download. Reuse Of The Code Is Permitted, InWhole Or In Part, Including The Creation Of Derivative Works, Provided That YouAcknowledge That You Are Using It And Identify The Source: Title, Publisher AndYear.
5. Limited Warranty
Manning Warrants That The Ebook Files, A Copy Of Which You AreAuthorized To Download, Are Free From Defects In The Operational Sense ThatThey Can Be Read By A Pdf Reader Or Epub Reader, Or Other. Except For ThisExpress Limited Warranty, Manning Makes And You Receive No Warranties, Express,Implied, Statutory Or In Any Communication With You, And Manning SpecificallyDisclaims Any Other Warranty Including The Implied Warranty Of MerchantabilityOr Fitness Or A Particular Purpose. Manning Does Not Warrant That The OperationOf The Ebook Will Be Uninterrupted Or Error Free. If The Ebook Was Purchased InThe United States, The Above Exclusions May Not Apply To You As Some States DoNot Allow The Exclusion Of Implied Warranties. In Addition To The AboveWarranty Rights, You May Also Have Other Rights That Vary From State To State.
6. Limitation Of Liability
In No Event Will Manning Be Liable For Any Damages, WhetherArising For Tort Or Contract, Including Loss Of Data, Lost Profits, Or OtherSpecial, Incidental, Consequential, Or Indirect Damages Arising Out Of The UseOr Inability To Use The Ebook.
7. General
This Agreement Constitutes The Entire Agreement Between You AndManning And Supersedes Any Prior Agreement Concerning The Ebook. This AgreementIs Governed By The Laws Of The State Of New York.