Introduction to Generative Deep Learning

Maru Tech šŸž
Data And Beyond
Published in
6 min readSep 2, 2023
Photo by Ina RH on Unsplash

Hey there, curious minds! šŸŒŸ If youā€™ve ever been intrigued by the world of generative AI , get ready to embark on this exciting journey iā€™ve got to you a very interesting topic , drum roll šŸ„šŸ„šŸ„ it is the generative deep learning

well many of you are likely acquainted with various deep learning approaches such as regression and classification , these techniques primarily fall under the umbrella of discriminative models , they excel at a pivotal task which is identifying patterns and relationships within dataā€™ Their focus is on mapping input data directly to corresponding labels or categories as depicted in the following figure

figure 01 : discriminative learning

However, in a world that values innovation and creativity, there arises a pressing demand for AI systems that transcend pattern recognition , these systems should generate content thatā€™s entirely new and imaginative and here where generative models come into play

Generative models had paved the way for machines to emulate human-like creativity and innovation by learning the underlying structures of data, these models become capable of producing new samples that appear as it have been generated using the same rules as the original data , figure 02 illustrates this process more clearly

figure 02 : generative learning

let us explore a tangible example to understand more

depict having a dataset containing paintings by Picasso and other artists

figure 03 : Photo by Mayur Deshpande on Unsplash

in a discriminative model, you could create a model that learns that certain shapes, colors, and structures are more likely to be painted by Picasso rather than other artists as depicted in fig1 . However, this approach requires labeled data, as it aims to model the probability of a label (artist) given an observation (painting) p(artist\painting)

In contrast, a generative model doesnā€™t need labels since it aims to model only the probability of observing an observation p(painting) , capturing a holistic understanding of the data distribution

note : There are also conditional generative models that can model conditional probabilities, such as p(x|y), which is the probability of observing x with a specific label y

by this point, you likely possess a solid grasp of the main differences between generative and discriminative models

Now, itā€™s time for us to create our very first generative model ā€¦ so letā€™s dive in!

Photo by Julian Hochgesang on Unsplash

Imagine youā€™re on a journey to uncover the hidden patterns behind a set of observations. These observations were created using a mysterious rule, letā€™s call it Pdata. Your task now is to dive into this sea of data and pick a point in the below figure space that feels like itā€™s part of the same family as those existing dots

let me guess , your intuition had led you to choose a spot inside the yellow circle, didnā€™t it?

well this yellow circle that youā€™ve imagined represents something remarkable , itā€™s your first attempt at building a generative model !!!!

a model that can create new data points that looks like it has been generated by the same rule in which the training set observations were generated , in other words your brain has constructed a model which is an estimate of pdata that approximatly captures its underlying distribution

Now, think about all possible dots that could be part of Pmodel, forming a space of their own ā€¦.. thatā€™s the sample space. The sample space covers every imaginable dot that your Pmodel could create it is where your new samples should be picked from

an important thing to mention is that Pmodel has three remarkable traits: accuracy, generation, and representation.

Accuracy because itā€™s almost like a twin of Pdata, generating points that match the rule closely

Generation because it can whip up new dots that look like theyā€™re part of the family, even if youā€™ve never seen them before

and representation because it encapsulates the essence of Pdata, capturing its hidden patterns

Now, letā€™s take a look at the original distribution of Pdata (red)

As you observe, our model Pmodel slightly extends beyond the boundaries of the actual distribution on the right side , while covering only a small portion of the actual left side

Pmodel might include all or just some of the observations generated by Pdata , interestingly Pmodel can even create new observations that donā€™t precisely match Pdata , however, in spite of these characteristics, Pmodel remains easy to sample from itā€™s nearly accurate and represents the essence of Pdata.

Considering this, we can conclude that Pdata serves as a potential estimation of Pmodel. This is a significant achievement ā€” youā€™ve effectively built your very first generative model!

so congratulations on reaching this milestone!

Representation learning

lets talk a little bit about representation learning , many generative models involve representation learning as a foundational step , they require a meaningful and informative representation of the data to effectively learn and model the dataā€™s distribution which in turn enhances their ability to generate realistic and coherent samples

when it comes to images , whether theyā€™re simple 2D pictures or complex 3D constructs , the way we represent them is often quite complex with many details . however , this complexity can become a problem when we want to change these representations or create new ones that look just like the originals , hereā€™s where representation learning steps in, and itā€™s simpler than it sounds ā€¦ it involves converting these complex representations into a simpler version , sort of like simplifying a puzzle. we call this simplified version the ā€œlatent spaceā€ , this process makes it easier to work with the data and perform actions like transforming or creating new content

Think of explaining a cylinder to someone else. You donā€™t need to explain every pixel wise little detail to them , just telling them about its height and radius is enough . This idea is similar to representation learning. Itā€™s about capturing the most important details in a simpler form thatā€™s easy to work with

the true magic happens when we add the concept of a ā€œmapping functionā€ this function learns how to take a point in the simplified latent space and translate it back into the original, more complex representation . Itā€™s like taking the height and radius of a cylinder and being able to draw the entire shape

this process isnā€™t just about recreating what weā€™ve seen before , itā€™s about being able to change things in the simplified version and then translate those changes back into the original

such as changing the height value of the simplified cylinder representation , this change creates an entirely new one that still follows the same basic rules as the others

figure 04 : cylinder shapes

conclusion

In conclusion , weā€™ve only scratched the surface of generative learning and its latent space magic in this blog post but thereā€™s more to explore!

Stay tuned for upcoming parts where weā€™ll dive deep into specific generative learning models like GANs and VAEs, unraveling their mysteries and applications

Muchas gracias for reading

Photo by Timothy Wolff on Unsplash

References

  • Generative Deep Learning, 2nd Edition Oreilly

--

--

Maru Tech šŸž
Data And Beyond

Deep learning & computer vision engineer | Algeria | Data And Beyond Author