-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Strange behaviour of loss value over the phase of trainging #690
Comments
Hi @ziadloo , In your case the loss seems to diverge, I would recommend to decrease your Regards, |
Hi @Celebio , Thanks for the insight. Could you please verify my understanding?
Regards, |
In case this might be helpful to anyone else, after changing the params to this:
The problem was fixed and the loss value progress changed to this: |
Hi @ziadloo,
Best, |
Does Fasttext have a built-in command that draws this loss plot over progress (or preferably over epoch) after fitting a skipgram model? |
AFAIK, fasttext does not have a built-in command to generate the plots. Personally, I used the progress output of the fasttext and saved it in a file (
Then I simply saved the results to a text file and used a spreadsheet software (in my case it was LibreOffice's Calc) to plot the chart. Cheers, |
In your explanation of getting loss values over training phase, you mentioned (fasttext ... > ./skipgram.out). I tried the same but I think only the final stats are stored as shown below. How do I save the intermediate loss values too in the file? Thanks. |
@VETURISRIRAM I faced the same problem while working on Linux but with Mac, I got the results at every epoch level. |
To make this loss tracking work in Linux you need to capture the loss outputs and then then replace the # ./fastText/fasttext skipgram -input sentences.txt -output sentences.txt -dim 100 &> progress.txt
# cat progress.txt | sed -e 's/\r/\n/g' > progress_with_newlines.txt Then you can use @ziadloo 's python code, i.e. modify the originally posted code fp = open('./progress_with_newlines.txt')
start = False
i = 0
loss = []
line = fp.readline().strip()
while line or i < 10:
if line.startswith('Progress: 0.0% words/sec/thread:'):
start = True
if start:
i = i + 1
columns = line.split(' ')
if len(columns) >= 11:
loss.append(float(columns[10]))
line = fp.readline().strip()
sample_count = len(loss)
window_size = int(sample_count / 1000.0)
summations = []
counts = []
for i, sample in enumerate(loss):
group = int(i / window_size)
if len(summations) - 1 < group:
summations.append(0.0)
counts.append(0)
summations[group] = summations[group] + sample
counts[group] = counts[group] + 1
for group, sums in enumerate(summations):
print(sums / float(counts[group])) If you do not want to waste time with visualization you can use: # less progress_with_newlines.txt and then just page-scroll through the file quickly by holding |
Hi @ziadloo, one question, to replicate your approach: how did you dump the loss value during your model training? Did you work in a jupyter notebook? Thanks and best, |
I'm using
fastText
to calculate word2vec for a corpus of text that I have like this:During the phase of training, I dumped the loss value reported by the utility and then plotted the progress of this loss value over the course of training phase:
I omitted
x
axis labels since they didn't make sense. But for the sake of completeness,My question is, why the loss value is going up at first? Does this mean that I'm better off not training so long and stop once the loss value is 2 (at the beginning)?
The text was updated successfully, but these errors were encountered: