Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Training accuracy #10

Closed
niddal-imam opened this issue May 19, 2019 · 19 comments
Closed

Training accuracy #10

niddal-imam opened this issue May 19, 2019 · 19 comments

Comments

@niddal-imam
Copy link

Hi Holmeyoung,

I have 20,000 training samples and 30 characters. I have been trying to train the model but the accuracy does not add up. How should I set the parameters?

@Holmeyoung
Copy link
Owner

Hi, did the training loss reduce? If yes, we can be patient, and the accuracy will be better after several epoch!

@niddal-imam
Copy link
Author

Hi,

Ys, it reduces very slowly. I will give it more time.

Thanks

@Holmeyoung
Copy link
Owner

Hi, how is the training accuracy? If your training accuracy become up and down, you can turn down the lr to 0.0001, just like i have said in #2 .

@niddal-imam
Copy link
Author

Hi,

Yes, exactly it keeps fluctuating. I will change lr, and see.

Thanks

@niddal-imam
Copy link
Author

Hi Holmeyoung,

I was able to train the model after generating clean dataset. However, my question is when to stop the training? the accuracy is increasing and about to reach 100 %, which may case the model to overfitting. So, when to stop?

Thanks,

@Holmeyoung
Copy link
Owner

Hi, it's a good news.
About your question, so, it's the meaning of val dataset. And the common strategy is no-improvement-in-n. It menas we should write down the best accuracy, if the performence of our model on val dataset did't increase after several epoch, it's time to stop.
But, how to define several. When the accuracy up to stable, if the epoch number is 100 or 1000, so we should wait about 10 epoch or 20 epoch. But if after 10 epoch the model is trained well(in this case, the model usually up to 80 accuracy in 1 epoch.), wait about 3 to 5 epoch is OK.
And one more thing, it's also the meaning of saving the model every setting-number interval! To avoid missing the best one.
Hope this will help you.

@niddal-imam
Copy link
Author

Thank you again for your corporation. Yes, the accuracy became stable after 30 epoch with 95%. However, when I test the model by using new samples, it could not recognise the words. When I use samples similar to the ones used for training, it recognises them.

@Holmeyoung
Copy link
Owner

Holmeyoung commented May 22, 2019

Hi, since you want to predict on noisy images, you should't train on clean data. Try to make your training samples look like the image you actually want to predict on. If you just want to train on small dataset, you can add dropout to the net to avoid overfitting.
in models/crnn.py

nn.LSTM(nIn, nHidden, bidirectional=True)

to

nn.LSTM(nIn, nHidden, bidirectional=True, dropout=0.5)

@niddal-imam
Copy link
Author

Sure, I will try using the dropout.

Thanks

@aaobscure
Copy link

@Holmeyoung @niddal-imam

Hi guys,

I have a question,

I want to train on my dataset ( Farsi Language ), I cannot understand what the shape of the dataset should be?

In my problem, all of my images in the dataset have 5 sentences ( 3 numbers, 2 names) , can you tell me how to prepare for training?

I have to crop all of them, or I can train them in one image ( I mean all the 5 sentences in one image).

For example :
Sentence 1 : niddal
Sentece 2: 10
Sentence 3: Imam
.....

Best,

@niddal-imam
Copy link
Author

Hi,

From my experience, you have to crop all of your images. The dataset that I used contained sentences, but I cooped all the images to build my model. The shape of the dataset should be as Holmeyoung explains in the Readme file.

absolute/path/to/image/一身转战_0.jpg
一身转战
absolute/path/to/image/三千里_1.jpg
三千里
absolute/path/to/image/一剑曾当百万师_2.jpg
一剑曾当百万师
absolute/path/to/image/3.jpg
一剑曾当百万师
absolute/path/to/image/一 剑 曾 当 百 万 师_4.jpg
一 剑 曾 当 百 万 师
absolute/path/to/image/niddal.jpg
niddal
absolute/path/to/image/imam.jpg
imam

@aaobscure
Copy link

@niddal-imam

Thanks for your response.

There is no problem for training, but for testing, I want to give the whole image ( I mean all 5 sentences ) , is this model able to detect all 5 sentences in the test phase?

@niddal-imam
Copy link
Author

Yes, it can recognize sentences. However, words are going to be connected to each other. For example, Niddal Imam will be recognized as niddalimam.

@aaobscure
Copy link

@niddal-imam

So there is no way to correct this problem?

Also, I have another question:

In Farsi, such as Arabic, if two alphabets are connecting, the shape is changing such as "ح" with "حا", what should I do for this problem?

Again thanks for being kind.

@niddal-imam
Copy link
Author

I have not found a solution for this problem yet. However, in my project, I used a text detection model that can detect words instead of sentences. After that, the recognition model can extract words correctly. Regarding the second question, you are right the model will recognize "ح" and "ا" as "حا" because the letters are connected. I do not know how to solve such problem because CTC separates characters by blanks.

@aaobscure
Copy link

@niddal-imam

I have trained the network, but the problem is that the model is not saved??

The path in the "params.py" is expr, so this folder appears in my folder, but the weights are not saved!!

Do you know how to correct this?

@niddal-imam
Copy link
Author

Hi

You need to change these parameters:
displayInterval = 100
valInterval = 1000
saveInterval = 1000

For more information, please refer to #3 .

@SreenijaK
Copy link

SreenijaK commented Jul 18, 2019

@aaobscure was your issue resolved? even I'm not able to save my model to expr folder even with these parameters
displayInterval = 100
valInterval = 1000
saveInterval = 1000.

@niddal-imam can you help me here?

@niddal-imam
Copy link
Author

You can either change these parameters or use a large training dataset. For example:
displayInterval = 10
valInterval = 50
saveInterval = 50

If it does not work, lower these parameters.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants