Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The basic principle and keras implementation of conditional variational automatic Encoder CVAE

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

This article shows you the basic principle of conditional variational automatic encoder CVAE and how to implement keras. The content is concise and easy to understand, which can definitely brighten your eyes. I hope you can get something through the detailed introduction of this article.

Variational automatic Encoder (VAE) is a directional graphics generation model, which has achieved good results, and is one of the most advanced methods to generate the model. It assumes that the data is made up of some random processes involving an unnoticed continuous random variable z. It is assumed that the generated z is a priori distribution P θ (z) and the conditional generated data distribution P θ (X | z), where X represents these data. Z is sometimes referred to as a hidden representation of data X.

Like any other automatic encoder architecture, it has an encoder and a decoder. The encoder part attempts to learn Q φ (z | x), which is equivalent to learning the hidden representation x or x of the learning data into a hidden (probability encoder) representation. The decoder part attempts to learn P θ (X | z) decoding hidden representation input space. The graphical model can be represented as the following figure.

Train the model to minimize the objective function

The first item of this loss is the expected negative logarithmic possibility of rebuilding errors or data points. The expectation is about the distribution of the encoder in the representation by taking some samples. This term encourages decoders to learn to reconstruct data when using samples from potential distributions. A large error indicates that the decoder cannot reconstruct the data.

The second item is the distribution qφ (z | x) and p (z) between Kullback-Leibler encoders. This divergence measures how much information is lost when using Q to represent a priori on z and encourages its value to be a Gaussian distribution.

During the generation process, the samples from N (0jue 1) are simply input into the decoder. The training and generation process can be expressed as follows

A training-time variational self-encoder is implemented as a feedforward neural network, where P (X | z) is a Gaussian distribution. Red indicates a non-differentiable sampling operation. Blue indicates loss calculation

Test-time variational "automatic encoder", which allows us to generate new samples. The "encoder" path is simply discarded.

The reason for such a brief description of VAE is that VAE is not the main focus of this article, but is closely related to the main theme of this article.

One of the problems with generating data with VAE is that we have no control over the type of data generated. For example, if we train VAE with a MNIST data set and try to generate an image by entering Z ~ N into the decoder, it will also produce different random numbers. If we train well, the image will be good, but we will not be able to control what number it produces. For example, you can't tell VAE to generate an image with the number "2".

To do this, we need to make some changes to the architecture of VAE. Given an input Y (the label of the image), we want to generate the model to generate the output X (image). Therefore, the process of VAE will be modified as follows: in view of the fact that the observation of YMagnez is derived from the prior distribution P θ (z | y) and the output distribution P θ produces x (x | ymemz). Note that for simple VAE, it used to be P θ (z) and the output is made up of P θ (x | z).

Visual representation tasks in VAE

Here the encoder part attempts to learn Q φ (z | x, y), which is equivalent to learning hidden representative data or encoding x to y conditions. The decoder section attempts to hide y that represents the learning P θ (x | z, y) decoding and hides the input space condition. The graphical model can be represented as shown in the following figure.

The neural network structure of conditional VAE (Conditional VAE) can be expressed as shown in the following figure.

X is like. Y is the label of the image, which can be represented by a discrete vector.

A keras implementation of CVAE: https://github.com/nnormandin/ConditionalVAE/blob/master/ConditionalVAE.ipynb

The above is the basic principle of conditional variational automatic encoder CVAE and what is the implementation of keras. Have you learned the knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, you are welcome to follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report