Open ademuro20 opened 4 years ago
The error message is caused by pytorch's expand
function. See the docs at: https://pytorch.org/docs/stable/tensors.html#torch.Tensor.expand
expand
is related to the shapes of tensors, and my guess is that the shapes of your tensors are not what you think they are. You should print the shapes of all your tensors, and I think that might help. In particular, your weight
tensor either has the wrong shape or you are using an incorrect formula to create it.
PS. I've edited your comment to improve formatting. When you're including multiline code blocks, you need to wrap the code in three backticks on their own line, not single backticks.
thank you!
should the shape of our scores tensor be the length of the input line x the number of categories/websites?
Ok, I created my scores with the shape being the length of the input line x the number of categories/websites and now I'm getting this error:
File "project.py", line 535, in line2img
im[i%maxwidth,im_height-i//maxwidth-1] = scores[i]
ValueError: only one element tensors can be converted to Python scalars
In that case, I think I'm still wrong about how I made my scores tensor. I also made another change like this
scores[i] = torch.abs(probs-probsW)
If I keep scores[i] = torch.abs(probs[i]-probsW[i])
, then the code only runs through my for loop once and I get an out of bounds IndexError
scores
should be a vector and not a higher order tensor. The sample code has a correctly shaped scores
vector that you can look at.
I am not sure how to fix this error and what is exactly going on. My weight tensor looks like this
and the code to build my score/weight is as follows: