EthanRosenthal / spacecutter

Ordinal regression models in PyTorch
https://www.ethanrosenthal.com/2018/12/06/spacecutter-ordinal-regression/
MIT License
136 stars 16 forks source link

There's a problem with my program. #7

Open shenao1994 opened 4 years ago

shenao1994 commented 4 years ago

RuntimeError: The size of tensor a (5) must match the size of tensor b (6) at non-singleton dimension 1 I'm working on a six classification task[0, 1, 2, 3, 4, 5].I found that cutpoints = num_ class - 1 in the code。 But in this way, the dimensions of cutpoints and X are not equal. I've seen your example, but I still don't know how to solve it. thank you!

EthanRosenthal commented 4 years ago

I don't really have enough information to help you debug this. All I can say is that there should be one fewer cutpoint than the number of classes that you're predicting. In your case, you have 6 classes, and you should have 5 cutpoints.

jlevy44 commented 2 years ago

@shenao1994 https://data.princeton.edu/wws509/notes/c6s5

gattia commented 12 months ago

For those that stumble upon this, the error is because your model that you are passing into OrdinalLogisticModel outputs n_classes values - it should output a single scalar value.