Re:从零开始的机器学习 - Encoder-Decoder架构

2,558 阅读2分钟

前言

最近在学习Adaptive Style Transfer并进行工程化实践,顺便总结一下深度学习中的Encoder-Decoder Architecture。

正文

Encoder-Decoder(编码-解码)是深度学习中非常常见的一个模型框架,一个encoder是一个接收输入,输出特征向量的网络(FC, CNN, RNN, etc)。这些特征向量其实就是输入的特征和信息的另一种表示。

编码实际上就是对内容的另一种表示

decoder同样也是一个网络(通常与编码器相同的网络结构,但方向相反),它从编码器获取特征向量,并输出与实际输入或预期输出最近似的结果,比如下图

准确的说,Encoder-Decoder并不是一个具体的模型,而是一类框架。Encoder和Decoder部分可以是任意的文字,语音,图像,视频数据,模型可以采用CNN,RNN,BiRNN、LSTM、GRU等等。所以基于Encoder-Decoder,我们可以设计出各种各样的应用算法。

encoder使用decoder进行训练,并且没有label(无监督)。损失函数中包含实际输入(actual input)和重构输入(reconstructed input)之间的差异(delta)。

一旦经过训练,encoder将给出输入的特征向量,解码器可以使用该特征重构输入。

这种技术被用于非常多不同的应用中,比如翻译、生成模型(generative models)等。

不过通常应用都不会重新构建原有的输入,而是 map/translate/associate 输入至特定的输出。比如把法语翻译成英语等。

具体例子

Autoencoder

自动编码器神经网络是一种无监督机器学习算法、有三层的神经网络:输入层、隐藏层(编码层)和解码层。该网络的目的是重构其输入,使其隐藏层学习到该输入的良好表征。其应用了反向传播,可将目标值设置成与输入值相等。自动编码器属于无监督预训练网络(Unsupervised Pretained Networks)的一种。其结构如下图所示:

[图片来源:深度学习:自动编码器基础和类型|机器之心]
比如2018年比较火的 Wasserstein自编码器。

CNN

In a CNN, an encoder-decoder network typically looks like this (a CNN encoder and a CNN decoder):

This is a network to perform semantic segmentation of an image. The left half of the network maps raw image pixels to a rich representation of a collection of feature vectors. The right half of the network takes these features, produces an output and maps the output back into the “raw” format (in this case, image pixels).

RNN

In an RNN, an encoder-decoder network typically looks like this (an RNN encoder and an RNN decoder):

This is a network to predict responses for incoming emails. The left half of the network encodes the email into a feature vector, and the right half of the network decodes the feature vector to produce word predictions.

Adaptive Style transfer

后记

参考资料

中文一个指导性文章 blog.csdn.net/xbinworld/a…

机器之心的 www.jiqizhixin.com/graph/techn…

What is an Encoder/Decoder in Deep Learning? www.quora.com/What-is-an-…

Is there a difference between autoencoders and encoder-decoder in deep learning? www.quora.com/Is-there-a-…