Why is Pytorch Lightning `validation_step` executed more oftener than defined in `val_check_interval`?
Question:
I have a dataset with 20 rows and want to have four times a Pytorch Lightning validation_step
called on this dataset. I am setting my
`val_check_interval=0.25`,
`eval_batch_size=4` and
`num_train_epochs=1`
. Thats my validation_step:
def validation_step(self, batch, batch_idx):
print("+"* 30)
What I expect is to see the print
command four times because of the val_check_interval
instead the print appears seven times. Why is this the case?
Answers:
You need to set the value num_train_epochs to 4 to print 4 times. Currently validation_step is being called 20 times as the value of epoch is 1
val_check_interval and eval_batch_size don’t determine the validation_step calls.
use val_check_interval for validation > 1 per training epoch
Use check_val_every_n_epoch for validation for lower frequency
I have a dataset with 20 rows and want to have four times a Pytorch Lightning validation_step
called on this dataset. I am setting my
`val_check_interval=0.25`,
`eval_batch_size=4` and
`num_train_epochs=1`
. Thats my validation_step:
def validation_step(self, batch, batch_idx):
print("+"* 30)
What I expect is to see the print
command four times because of the val_check_interval
instead the print appears seven times. Why is this the case?
You need to set the value num_train_epochs to 4 to print 4 times. Currently validation_step is being called 20 times as the value of epoch is 1
val_check_interval and eval_batch_size don’t determine the validation_step calls.
use val_check_interval for validation > 1 per training epoch
Use check_val_every_n_epoch for validation for lower frequency