Pytorch-CapsuleNet
Pytorch-CapsuleNet copied to clipboard
How to change the number of categories of a classification to apply to your own dataset?
File "C:\Users\23671\Desktop\CNN\self_conv\DDR\CNN_2d.py", line 405, in forward u = u.view(x.size(0), self.num_routes, -1) RuntimeError: shape '[2, 1152, -1]' is invalid for input of size 1125888
When applied to my own dataset, the code error input size is greater than the convolutional kernel size, so I changed padding to 1 and changed the convolutional kernel size at the same time, but the error was reported as above, I guess the number of categories that did not change the classification was 5, but I don't know where to change it
u = u.view(x.size(0), self.num_routes, -1)
the size of u is [2 8 32 3 733] but the classes is 5, I wonder how to fix the error
u = u.view(x.size(0), self.num_routes, -1)the size of u is [2 8 32 3 733] but the classes is 5, I wonder how to fix the error
Do you mind specifying the dataset name you are trying to work with here?
The desired number of classes are defined by the variable config.dc_out_channels in the Config class. If your images are of different shape than 28 x 28 as used in the example tests, you also need to make sure that the second and third value in pc_num_routes and dc_num_routes are updated with the actual feature map dimensions outputted from the conv layer.