DeepSpeech icon indicating copy to clipboard operation
DeepSpeech copied to clipboard

Training loss increasing

Open aaronzira opened this issue 9 years ago • 10 comments

Training DS2-V2 on TED with run-ted.sh, learning_rate = 0.0001, dropout_rate = 0.30, train/dev/test batch sizes = 8/4/4 and 16/8/8. Added a tf.summary.scalar() on the fourth and final output of get_tower_results (i.e., tf.reduce_mean(tower_avg_losses, 0)). Tensorboard graph of this value appears as follows (major drops are a restart and a new epoch):

loss

Am I tracking the wrong value, or is anyone else experiencing something similar?

aaronzira avatar May 03 '17 23:05 aaronzira

@aaronzira How do the normally logged loss outputs look

kdavis-mozilla avatar May 04 '17 05:05 kdavis-mozilla

Looks as expected for the 0th epoch:

I Validation of Epoch 0 - loss: 136.320444

aaronzira avatar May 05 '17 01:05 aaronzira

Does the loss decrease over many epochs? Could you post the entire log not just the first epoch?

kdavis-mozilla avatar May 05 '17 05:05 kdavis-mozilla

Had to restart runs a few times and they were quite slow to begin with, so that's all I had at the time. Just started a fresh run with more GPUs that should move much quicker; will update when I have something more useful.

aaronzira avatar May 06 '17 22:05 aaronzira

There were a few hiccups in finding a batch size that wouldn't cause OOM issues, which explains the delay between "STARTING Optimization" and "Training of Epoch 1", the three drops in the "loss" graph, and the three spikes in the "WER" graph. From around 1.8k steps the run was executed with batch sizes of 8/4/4, without interruption except near the end of the 6th epoch in order to change the stop epoch from 10 to 6, as the model appeared to be overfitting, judging by the train and validation losses.

2017-05-07 05:05:05 - I - STARTING Optimization 2017-05-07 09:58:02 - I - Training of Epoch 1 - loss: 93.954895 2017-05-07 09:59:16 - I - Validation of Epoch 1 - loss: 109.708347 2017-05-07 15:05:44 - I - Training of Epoch 2 - loss: 76.219679 2017-05-07 15:07:04 - I - Validation of Epoch 2 - loss: 109.436159 2017-05-07 20:23:01 - I - Training of Epoch 3 - loss: 63.856714 2017-05-07 20:24:23 - I - Validation of Epoch 3 - loss: 106.021344 2017-05-08 01:38:04 - I - Training of Epoch 4 - loss: 53.818496 2017-05-08 01:39:23 - I - Validation of Epoch 4 - loss: 109.147173 2017-05-08 06:48:56 - I - Training of Epoch 5 - loss: 45.653575 2017-05-08 06:50:16 - I - Validation of Epoch 5 - loss: 114.789903 2017-05-08 12:01:17 - I - Training of Epoch 6 - loss: 38.927592 2017-05-08 12:16:30 - I - Test of Epoch 7 - WER: 0.396341, loss: 81.3622112009, accuracy: 0.192951

As stated in the initial comment on this issue, the "loss" values plotted below are written from the "loss" tensor returned by get_tower_results() called within train(). While the running average increases within an epoch, the values clearly decrease from one epoch to the next.

train_loss

The values in the following plot were written from tensor "accuracy" (called "mean_edit_distance" in master branch) at the same time as "loss" above, and is taken to be equivalent to training WER (is this assumption correct?).

train_wer

Ultimately I'm wondering if others are seeing this overfitting as demonstrated by the epoch-final train and val losses, and if "accuracy"/"mean_edit_distance" does in fact correspond to WER.

aaronzira avatar May 08 '17 22:05 aaronzira

Ultimately I'm wondering if others are seeing this overfitting

The overfitting can be combated through using fewer epochs or a larger dropout.

(does) "accuracy"/"mean_edit_distance" does in fact correspond to WER

"accuracy"/"mean_edit_distance"[1] is related to WER[2] be they are different things.

kdavis-mozilla avatar May 09 '17 07:05 kdavis-mozilla

AFAIK the increasing loss within the epochs is due to curriculum learning. Later examples are longer and thus harder, so the last batches will have a higher average loss than the first ones.

On May 9, 2017 4:46 AM, "Kelly Davis" [email protected] wrote:

Ultimately I'm wondering if others are seeing this overfitting

The overfitting can be combated through using fewer epochs or a larger dropout.

(does) "accuracy"/"mean_edit_distance" does in fact correspond to WER

"accuracy"/"mean_edit_distance"[1 https://en.wikipedia.org/wiki/Edit_distance] is related to WER[2 https://en.wikipedia.org/wiki/Word_error_rate] be they are different things.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/mozilla/DeepSpeech/issues/559#issuecomment-300087732, or mute the thread https://github.com/notifications/unsubscribe-auth/AAdH1rCXW4ddvuYMl3CA6DcWW6nkqMfZks5r4BnWgaJpZM4NQFQ9 .

reuben avatar May 09 '17 22:05 reuben

Awesome -- thank you!

Also, I was getting used to having run this with DeepSpeech1, but now I am wondering why we are making use of dropout at all in DeepSpeech2. It seems the flags are set up for DS1's architecture (dropout applied to all the feed-forward layers), despite the complete change of the graph in DS2 (no dropout, yes batch norm). Am I mistaken?

aaronzira avatar May 10 '17 20:05 aaronzira

There is no dropout in DS2, I just haven't updated the flags because the branch is a WIP and not intended for outside usage yet (although that doesn't seem to stop anyone :P).

I believe this issue can be closed now. Feel free to reopen if you think it hasn't been addressed.

reuben avatar May 10 '17 20:05 reuben

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

lock[bot] avatar Jan 03 '19 17:01 lock[bot]