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
+12-12Lines changed: 12 additions & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1446,11 +1446,11 @@ _<small>➔ вывод:</small>_
1446
1446
1447
1447
### Оптимизатор и функция потерь
1448
1448
1449
-
We're going to use [tf.keras.optimizers.Adam](https://www.tensorflow.org/api_docs/python/tf/keras/optimizers/Adam) optimizer with [tf.keras.losses.sparse_categorical_crossentropy()](https://www.tensorflow.org/api_docs/python/tf/keras/losses/sparse_categorical_crossentropy) loss function to train the model:
1449
+
В качестве оптимизатора возьмем [tf.keras.optimizers.Adam](https://www.tensorflow.org/api_docs/python/tf/keras/optimizers/Adam), а для функции потерь воспользуемся функцией [tf.keras.losses.sparse_categorical_crossentropy()](https://www.tensorflow.org/api_docs/python/tf/keras/losses/sparse_categorical_crossentropy):
1450
1450
1451
1451
```python
1452
-
# An objective function.
1453
-
# The function is any callable with the signature scalar_loss = fn(y_true, y_pred).
For model training process we may configure a[tf.keras.callbacks.EarlyStopping](https://www.tensorflow.org/api_docs/python/tf/keras/callbacks/EarlyStopping) callback. It will stop the training automatically in case if model is not improving for several epochs anymore:
1493
+
Во время тренировки модели мы можем воспользоваться коллбеком[tf.keras.callbacks.EarlyStopping](https://www.tensorflow.org/api_docs/python/tf/keras/callbacks/EarlyStopping). Он останавливает процесс тренировки автоматически, если показатели модели ухудшаются в течение определенного количества эпох:
Let's also configure a [tf.keras.callbacks.ModelCheckpoint](https://www.tensorflow.org/api_docs/python/tf/keras/callbacks/ModelCheckpoint) checkpoint that will allow us to periodically save trained weights to the file so that we could restore the model from weights afterwards.
1506
+
Мы также можем настроить автоматическое сохранение параметров модели во время тренировки с помощью коллбека [tf.keras.callbacks.ModelCheckpoint](https://www.tensorflow.org/api_docs/python/tf/keras/callbacks/ModelCheckpoint). Это позволит нам в будущем восстановить модель из сохраненных контрольных точек без ее тренировки.
Let's train our model for`500`epochs with`1500`steps per each epoch. For each epoch step the batch of `64`recipes will be fetched and gradient descent will be executed for those `64`recipes of length `2000`step by step.
1522
+
Будем тренировать модель в течение`500`эпох с`1500`шагами на каждую эпоху. На каждом шагу, модель будет обучаться на группе из `64`рецептов. Градиентный спуск на каждом также будет выполнен для группы из `64`рецептов (каждый из которых состоит из `2000`символов).
1523
1523
1524
-
If you're experimenting with training parameters it might make sense to reduce the number of epochs to, let's say `20`along with the number of steps per epoch and then see how the model performs under that conditions. If the model improves its performance you may add more data (steps and epochs) to the training process. It might save you some time while you adjust parameters.
1524
+
Если вы экспериментируете с тренировочными параметрами, то, возможно, имеет смысл уменьшить количество эпох до, скажем, `20`вместе с количеством шагов на эпоху, а затем посмотреть, как модель работает в этих условиях. Если модель улучшит свою производительность, вы можете добавить больше данных (шагов и эпох) в тренировочный процесс. Это может сэкономить время на настройку параметров модели.
0 commit comments