MulaiMulai sekarang secara gratis

Complete text reversing model

You will now implement the decoder part of the text reversing model, which will convert the context vector from the encoder to reversed words.

You will be defining two functions onehot2words() and decoder(). The onehot2words() function takes in a list of ids and a dictionary index2word and converts an array of one-hot vectors to a list of words. The decoder() function takes in the context vector (i.e., list of word ids) and converts it to the reversed list of words.

For this exercise, the index2word dictionary, the context vector context, the encoder() function and the words2onehot() functions will be provided.

Latihan ini adalah bagian dari kursus

Machine Translation with Keras

Lihat Kursus

Latihan interaktif praktis

Cobalah latihan ini dengan menyelesaikan kode contoh berikut.

# Define the onehot2words function that returns words for a set of onehot vectors
def ____(onehot, index2word):
  ids = np.____(____, ____=____)
  res = [____[____] for id in ids]
  return res
Edit dan Jalankan Kode