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

Concatenate last batches for batched inference #200

Open
wants to merge 2 commits into
base: batched-inference-and-padding
Choose a base branch
from

Conversation

CeliaBenquet
Copy link
Member

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 to batch_size).

Copy link
Member

@stes stes left a 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?

@cla-bot cla-bot bot added the CLA signed label Nov 29, 2024
@CeliaBenquet CeliaBenquet requested a review from stes November 29, 2024 09:38
Comment on lines +1511 to +1525
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)
Copy link
Member

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?

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

Successfully merging this pull request may close these issues.

2 participants