Hello, and welcome to this final week of this course,
as well as to the final week of this sequence of
five courses in the deep learning specialization.
You're nearly at the finish line.
In this week, you hear about sequence-to-sequence models,
which are useful for everything from machine translation to speech recognition.
Let's start with the basic models and then later this week you,
hear about beam search,
the attention model, and we'll wrap up
the discussion of models for audio data, like speech.
Let's get started.
Let's say you want to input a French sentence like Jane visite l'Afrique en septembre,
and you want to translate it to the English sentence,
Jane is visiting Africa in September.
As usual, let's use x<1> through x,
in this case <5>,
to represent the words in the input sequence,
and we'll use y<1> through y<6> to represent the words in the output sequence.
So, how can you train a new network to input the sequence x and output the sequence y?
Well, here's something you could do,
and the ideas I'm about to present are mainly from these two papers due to Sutskever,
Oriol Vinyals, and Quoc Le,
and that one by Kyunghyun Cho,
Bart van Merrienboer, Caglar Gulcehre, Dzmitry Bahdanau, Fethi Bougares,
Holger Schwen, and Yoshua Bengio.
First, let's have a network,
which we're going to call the encoder network be built as a RNN,
and this could be a GRU and LSTM,
feed in the input French words one word at a time.
And after ingesting the input sequence,
the RNN then offers a vector that represents the input sentence.
After that, you can build a decoder network which I'm going to draw here,
which takes as input
the encoding output by the encoder network shown in black on the left,
and then can be trained to output
the translation one word
at a time until eventually it outputs say,
the end of sequence or end the sentence token upon
which the decoder stops and as usual we could take
the generated tokens and feed them to the next [inaudible]
in the sequence like we 're doing before when synthesizing text using the language model.
One of the most remarkable recent results in deep learning is that this model works,
given enough pairs of French and English sentences.
If you train the model to input
a French sentence and output the corresponding English translation,
this will actually work decently well.
And this model simply uses an encoder network,
whose job it is to find an encoding of the input French sentence and then use
a decoder network to then generate the corresponding English translation.
An architecture very similar to this also works
for image captioning so given an image like the one shown here,
maybe wanted to be captioned automatically as a cat sitting on a chair.
So how do you train a new network to input an image and
output a caption like that phrase up there?
Here's what you can do. From the earlier course on [inaudible] you've seen
how you can input an image into a convolutional network,
maybe a pre-trained AlexNet,
and have that learn an encoding or learn a set of features of the input image.
So, this is actually
the AlexNet architecture and if we get rid of this final Softmax unit,
the pre-trained AlexNet can give you
a 4096-dimensional feature vector of which to represent this picture of a cat.
And so this pre-trained network can be the encoder network for the image
and you now have a 4096-dimensional vector that represents the image.
You can then take this and feed it to an RNN,
whose job it is to generate the caption one word at a time.
So similar to what we saw with machine translation translating from French to English,
you can now input a feature vector describing the input and then have it
generate an output sequence or output set of words one word at a time.
And this actually works pretty well for image captioning,
especially if the caption you want to generate is not too long.
As far as I know,
this type of model
was first proposed by Junhua Mao, Wei Xu, Yi Yang, Jiang Wang, Zhiheng Huang,
and Alan Yuille, although it turns out there were
multiple groups coming up with
very similar models independently and at about the same time.
So two other groups that had done very similar work
at about the same time and I think independently of Mao et al were Oriol Vinyals,
Alexander Toshev, Samy Bengio,
and Dumitru Erhan, as well as Andrej Karpathy and Fei-Fei Yi.
So, you've now seen how a basic sequence-to-sequence model works,
or how a basic image-to-sequence or image captioning model works,
but there are some differences between how you would run a model like this,
so generating a sequence compared to how you were
synthesizing novel text using a language model.
One of the key differences is,
you don't want a randomly chosen translation,
you maybe want the most likely translation,
or you don't want a randomly chosen caption, maybe not,
but you might want the best caption and most likely caption.
So let's see in the next video how you go about generating that.