-
Notifications
You must be signed in to change notification settings - Fork 78
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
Concatenate last batches for batched inference #200
base: batched-inference-and-padding
Are you sure you want to change the base?
Concatenate last batches for batched inference #200
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, @CeliaBenquet . Can you add a test case which highlights the issue (and breaks in the "old" codebase), and then confirm that your fix passes the test?
def test_last_incomplete_batch_smaller_than_offset(): | ||
""" | ||
When offset of the model is larger than the remaining samples in the | ||
last batch, an error could happen. We merge the penultimate | ||
and last batches together to avoid this. | ||
""" | ||
train = cebra.data.TensorDataset(neural=np.random.rand(20111, 100), | ||
continuous=np.random.rand(20111, 2)) | ||
|
||
model = cebra.CEBRA(max_iterations=2, | ||
model_architecture="offset36-model-more-dropout", | ||
device="cpu") | ||
model.fit(train.neural, train.continuous) | ||
|
||
_ = model.transform(train.neural, batch_size=300) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the check here? i.e., what failed before the fix provided in this PR? It would be good to add some assert
statement.
Is it required to do full model fitting for this to work, or would it be possible to explicitly test the newly added function?
fix #199.
To still transform the extra samples that are not contained in a full batch while not getting an error regarding the next to last batch
batch_end_idx
above the length of the input, I propose to concatenate the penultimate batch (so the last complete batch) with the last batch (the incomplete batch from 1 tobatch_size
).