Skip to content

Fix classification labels for batch size 1#5

Closed
lukasugar wants to merge 1 commit into
Sllambias:mainfrom
MedARC-AI:classfication_batch_size_fix
Closed

Fix classification labels for batch size 1#5
lukasugar wants to merge 1 commit into
Sllambias:mainfrom
MedARC-AI:classfication_batch_size_fix

Conversation

@lukasugar
Copy link
Copy Markdown
Contributor

@lukasugar lukasugar commented May 18, 2026

When using batch_size=1 for smoke tests, squeeze() turns a [1, 1] label tensor into a scalar for batch_size=1,
which breaks CrossEntropyLoss with a batch-size mismatch. view(-1)keeps labels shaped as [B].

For batch sizes other than 1, the behavior remains the same.

@Sllambias
Copy link
Copy Markdown
Owner

Seems to also be included in #6 - just porting my comment here:

I am concerned this may cause issues for classification/regression inference. Have you tested that?
(And this shows that the full pipeline tests are long overdue..)

@lukasugar
Copy link
Copy Markdown
Contributor Author

Seems to also be included in #6 - just porting my comment here:

I am concerned this may cause issues for classification/regression inference. Have you tested that? (And this shows that the full pipeline tests are long overdue..)

Replied there:

I've tested both classification and regression and it works.
squeeze() and .view(-1) should behave the same - with view have support for scalars - for the current evals/finetuning setup.

Maybe we can close this PR and look at all the changes in the other one

@Sllambias Sllambias closed this May 29, 2026
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

Successfully merging this pull request may close these issues.

2 participants