Загрузка...

Pytorch LSTM Part 3

Today we are building an LSTM model in PyTorch, but first we have to finish vectorizing our training data. The model cannot learn from words until we turn each sentence into numbers. We lower case the text, split it into words, and map each word to an index, then we do the same for the tag labels.

A few bugs show up along the way: list comprehensions were hard to read, labels were not shaped right, and the embedding layer would not accept plain lists. We fix that by converting inputs to torch tensors and by padding so every sequence has the same length. We also hit a tricky issue where repeated words overwrote each other in our mapping, so we adjust the loop to handle one word at a time.

By the end, the forward pass runs and we are ready to start training with NLLLoss and SGD.

Видео Pytorch LSTM Part 3 канала Stephen Blum
Яндекс.Метрика
Все заметки Новая заметка Страницу в заметки
Страницу в закладки Мои закладки
На информационно-развлекательном портале SALDA.WS применяются cookie-файлы. Нажимая кнопку Принять, вы подтверждаете свое согласие на их использование.
О CookiesНапомнить позжеПринять