Pytorch-CapsuleNet icon indicating copy to clipboard operation
Pytorch-CapsuleNet copied to clipboard

How to change the number of categories of a classification to apply to your own dataset?

Open jiangye-git opened this issue 3 years ago • 3 comments

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

jiangye-git avatar May 14 '22 14:05 jiangye-git

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

jiangye-git avatar May 14 '22 15:05 jiangye-git

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?

amir-ghz avatar May 16 '22 11:05 amir-ghz

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.

kingkrugerham avatar Apr 23 '23 07:04 kingkrugerham