Costum dataset num_class issue and debug
Opened this issue · 0 comments
FORSOLADU commented
I found that if I use my own data set and change the class number to 7, an error will be reported:
UserWarning: Using a target size (torch.Size([4, 7, 64, 64])) that is different to the input size (torch.Size([4, 6, 64, 64])). This will likely lead to incorrect results due to broadcasting. Please ensure they have the same size
...
RuntimeError: The size of tensor a (6) must match the size of tensor b (7) at non-singleton dimension 1.
This is because the MCC output code writes the shape as a fixed value 6. The following is the debug report,
- models/CC.py
L14:
def __init__(self, net_name, gpu_id): -> def __init__(self, net_name, gpu_id, num_class):
L25:
self.CCN = ccnet() ->
if self.net_name == 'MCC': # +
self.CCN=ccnet(num_class=num_class) # +
else: # +
self.CCN = ccnet()
- models/counters/MCC.py
L160: self.output_layer = SCAModule(self.project_out, 6) -> self.output_layer = SCAModule(self.project_out, num_class)
- trainer.py
L36: self.net = CrowdCounter(self.net_name, self.gpu_id) -> self.net = CrowdCounter(self.net_name, self.gpu_id, self.num_classes)