Bug Description
In the ResNet18 model definition, num_classes is accepted
as an argument in __init__ but is completely ignored.
The final fully connected layer is hardcoded to output
1000 classes (ImageNet default), which causes silent
wrong behavior when the model is used for Renaissance OCR
classification tasks.
Location
File: [paste exact file path here]
Current Broken Code
class ResNet18(nn.Module):
def __init__(self, num_classes): # accepted but ignored!
super().__init__()
self.fc = nn.Linear(512, 1000) # hardcoded 1000 — BUG!
Fixed Code
class ResNet18(nn.Module):
def __init__(self, num_classes):
super().__init__()
self.fc = nn.Linear(512, num_classes) # uses argument correctly
Impact
- Model silently outputs wrong number of classes
- Will crash or give wrong results for any dataset
with classes ≠ 1000
- Renaissance OCR tasks have far fewer than 1000 classes
Proposed Fix
Replace hardcoded 1000 with num_classes in the
Linear layer definition.
I would like to submit a PR to fix this.
Bug Description
In the ResNet18 model definition,
num_classesis acceptedas an argument in
__init__but is completely ignored.The final fully connected layer is hardcoded to output
1000 classes (ImageNet default), which causes silent
wrong behavior when the model is used for Renaissance OCR
classification tasks.
Location
File: [paste exact file path here]
Current Broken Code
Fixed Code
Impact
with classes ≠ 1000
Proposed Fix
Replace hardcoded
1000withnum_classesin theLinear layer definition.
I would like to submit a PR to fix this.