Closed LeonHafner closed 3 days ago
Hi @LeonHafner thanks for posting this. Currently, apparently, we issue a warning in such cases, see https://github.com/scverse/scvi-tools/pull/2916 and the changelog. There is no logic fix. Will this not be enough for your case?
Otherwise, see my suggested fix here: https://github.com/scverse/scvi-tools/pull/3036 The idea is that in this case we will artificially add +1 to n_train and remove 1 from n_val, if possible (i.e if n_val by itself is larger than 2)
Hi @ori-kron-wis, thanks for the quick reply.
for me the quickest fix was to pass datasplitter_kwargs={"drop_last": True}
to the model.train
function. This simply drops the cell that remains in the last batch.
But as this is not a very nice solution, I would appreciate some logic being implemented into scVI to fix this. Your suggested fix is a great idea, hope you will be able to get it merged!
Best, Leon
@ori-kron-wis I didn’t come to fix it. I think we should add the cells to validation (and I would do it for less than 3 cells - sounds safer). We should set by default train_size and validation_size to None. If it’s None we change these small batches. If the user sets a custom value like 0.9 (old behavior), we don’t change the train cells and it still fails.
This bug has already been reported in several issues and on discourse: #2314 #2214 #221 #426 SCVI training fails if the
ceil(n_cells * 0.9) % 128 == 1
, where 0.9 is the training split and 128 the batch size. I thought the bug should be fixed with 1.2.0, but unfortunately it still occurs.It would be very cool, if you could find a fix for that, as that would allow users to remove unnecessary try-except blocks that change the batch size if the error occurs.
Thanks a lot!
Versions: