You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: assets/recipes_generation.ru.md
+17-16Lines changed: 17 additions & 16 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -597,9 +597,10 @@ _<small>➔ вывод:</small>_
597
597
> Number of eliminated recipes: 22726
598
598
> ```
599
599
600
-
We lost `22726` recipes during this filtering but now recipes' data is more dense.
600
+
Мы потеряли `22726` рецептов после фильтрации, но зато теперь список рецептов стал более однородным (плотным)
601
+
с точки зрения количества символов. Позже, каждый рецепт будет "подогнан" по длине к `MAX_RECIPE_LENGTH` путем добавления стоп-символа в конец строки. Фильтрация, которую мы только что сделали, по сути, снизит общее количество стоп-символов и увеличит "полезность" данных при тренировке. Например, `10` стоп-символов в наборе данных из `100` символов (`90%` полезных для тренировки сети данных) может быть лучше для обучения, чем `50` стоп-символов в наборе данных из `100` символов (`50%` полезных для тренировки сети данных).
601
602
602
-
### Summarizing dataset parameters
603
+
### Подытоживаем параметры набора данных
603
604
604
605
```python
605
606
TOTAL_RECIPES_NUM = len(dataset_filtered)
@@ -615,19 +616,19 @@ _<small>➔ вывод:</small>_
615
616
> TOTAL_RECIPES_NUM: 100212
616
617
> ```
617
618
618
-
Finally, we ended up with `~100k` recipes. Each recipe has `2000` characters length.
619
+
В итоге мы имеем `~100000` рецептов, каждый из которых будет иметь длину в `2000` символов.
619
620
620
-
## Creating vocabulary
621
+
## Создаем словарь
621
622
622
-
Recurrent neural network doesn't understand characters or words. It understands numbers instead. Therefore, we need to convert recipe texts to numbers.
623
+
Рекуррентные нейронные сети не понимают ни символов, ни слов. Вместо этого они понимают числа. Поэтому нам необходимо преобразовать текст рецептов (последовательность символов) в последовательность чисел.
623
624
624
-
In this experiment we're going to use a **character-level** language model based on multi-layer LSTM (Long Short-Term Memory) network (as opposed to **word-level** language model). It means that instead of creating unique indices for words we will create unique indices for characters. By doing that we let the network predict the next _character_ instead of the next _word_ in a sequence.
625
+
В этом эксперименте мы будем использовать модель **символьного уровня** (не словарного уровня), с архитектурой LSTM (Long Short-Term Memory). Это означает, что вместо создания уникальных индексов для слов мы будем создавать уникальные индексы для символов. Таким образом, мы позволяем сети предсказывать индекс следующего _символа_ вместо индекса следующего _слова_ в последовательности.
625
626
626
-
ℹ️ You may find more details about character-level RNNs explanation in the [Unreasonable Effectiveness of Recurrent Neural Networks](http://karpathy.github.io/2015/05/21/rnn-effectiveness/) article by _Andrej Karpathy_:
627
+
ℹ️ Более детально про языковую модель символьного уровня вы можете прочитать в статье [Unreasonable Effectiveness of Recurrent Neural Networks](http://karpathy.github.io/2015/05/21/rnn-effectiveness/).
627
628
628
-
To create a vocabulary out of recipes texts we will use [tf.keras.preprocessing.text.Tokenizer](https://www.tensorflow.org/api_docs/python/tf/keras/preprocessing/text/Tokenizer).
629
+
Для создания словаря из текста рецептов мы будем использовать [tf.keras.preprocessing.text.Tokenizer](https://www.tensorflow.org/api_docs/python/tf/keras/preprocessing/text/Tokenizer).
629
630
630
-
We also need to come with some unique character that will be treated as a _stop-character_ and will indicate the end of a recipe. We need it for recipe generation afterwards since without this stop-character we won't know where the end of a recipe that we're generating is.
631
+
Нам также необходимо выбрать уникальный символ, который мы будем использовать в качестве _стоп-символа_. Этот стоп-символ будет означать конец текста рецепта. Он нам понадобится во время генерации новых текстов.
To get a full size of a vocabulary we need to add `+1` to the number of already registered characters because [index `0` is a reserved index that won't be assigned to any word](https://www.tensorflow.org/api_docs/python/tf/keras/preprocessing/text/Tokenizer).
673
+
Для того, чтобы узнать окончательный размер словаря, нам необходимо добавить `+1` к числу ранее зарегистрированных символов потому что [нулевой индекс зарезервирован токенайзером и не будет присвоен ни одному из символов](https://www.tensorflow.org/api_docs/python/tf/keras/preprocessing/text/Tokenizer).
673
674
674
675
```python
675
676
VOCABULARY_SIZE = len(tokenizer.word_counts) + 1
@@ -683,7 +684,7 @@ _<small>➔ вывод:</small>_
683
684
> VOCABULARY_SIZE: 176
684
685
> ```
685
686
686
-
Let's play around with tokenizer dictionaries to see how we may convert characters to indices and vice-versa:
687
+
Давайте посмотрим, как теперь мы можем конвертировать символы в индексы и индексы в символы с помощью созданного словаря:
687
688
688
689
```python
689
690
print(tokenizer.index_word[5])
@@ -697,7 +698,7 @@ _<small>➔ вывод:</small>_
697
698
> ,
698
699
> ```
699
700
700
-
Let's try to convert character to index:
701
+
Конвертируем символ в индекс:
701
702
702
703
```python
703
704
tokenizer.word_index['r']
@@ -709,7 +710,7 @@ _<small>➔ вывод:</small>_
709
710
> 8
710
711
> ```
711
712
712
-
To illustrate what kind of characters form all the recipes in our dataset we may print all of them as an array:
713
+
Список всех символов, образующих весь набор данных с рецептами выглядит так:
713
714
714
715
```python
715
716
array_vocabulary = tokenizer.sequences_to_texts([[word_index] for word_index in range(VOCABULARY_SIZE)])
These are all the characters our RNN model will work with. It will try to learn how to assemble these characters into sequences that will look like recipes.
726
+
Это весь набор символов с которым будет работать нейронная сеть. Она будет учиться собирать эти символы в последовательности, которые в итоге должны быть читабельными и похожи на кулинарные рецепты.
726
727
727
-
Let's see how we may use `tokenizer` functions to convert text to indices:
728
+
Попробуем теперь конвертировать не один символ, а строку в последовательность индексов, используя `tokenizer`:
0 commit comments