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

TypeError: unsupported operand type(s) for %: 'int' and 'NoneType' #23

Open
cculin18 opened this issue Mar 11, 2022 · 4 comments
Open

Comments

@cculin18
Copy link

cculin18 commented Mar 11, 2022

Hi,
I got the problem, I can begin trainging the code. But while run epoch=2, it show this problem and stop to train.

File "train.py", line 212, in
trainer.train()
File "train.py", line 122, in train
if epoch % self.test_interval == 0 or epoch % self.save_interval == 0:
TypeError: unsupported operand type(s) for %: 'int' and 'NoneType'

@JingdiZhou
Copy link

yes ,I have met that problem too .So do someone have fixed it?

@JingdiZhou
Copy link

Hi bro ,so have you fixed this problem ?

@H-Blues
Copy link

H-Blues commented May 9, 2023

@cculin18 @JingdiZhou

Hi guys, I'm not sure whether you have solved this issue, but I encountered the same problem.
Upon checking, I found that the default value of the save_interval parameter was set to None, and you can see this in the parse_arguments() method, specifically line 29 in the train.py file.

At the same time, I noticed that @ParthPatel-ES fixed this issue in the Pull Request#14. He changed save_interval from None to 2 and used math.fmod() instead of % in line 122. I saw an explanation of differences for these two methods in a Q&A on Kaggle: https://www.kaggle.com/questions-and-answers/102766. He also modified some paths for better execution on Google Colab, great job!

Additionally, I believe that adding a condition check before the code in line 122 or using a try-catch block to catch exceptions are both viable solutions.

Best regards.

@JingdiZhou
Copy link

@cculin18 @JingdiZhou

Hi guys, I'm not sure whether you have solved this issue, but I encountered the same problem. Upon checking, I found that the default value of the save_interval parameter was set to None, and you can see this in the parse_arguments() method, specifically line 29 in the train.py file.

At the same time, I noticed that @ParthPatel-ES fixed this issue in the Pull Request#14. He changed save_interval from None to 2 and used math.fmod() instead of % in line 122. I saw an explanation of differences for these two methods in a Q&A on Kaggle: https://www.kaggle.com/questions-and-answers/102766. He also modified some paths for better execution on Google Colab, great job!

Additionally, I believe that adding a condition check before the code in line 122 or using a try-catch block to catch exceptions are both viable solutions.

Best regards.

I'm very appreciate your answer to me, which help me a lot in understanding the code

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

3 participants