Torch capsule-ru giving negative r2 score

I am applying bigru-capsule network for stock market forecasting on dow jones industrial average data.R2 score in training itself is coming negative.

code and data files available https://github.com/SamratSengupta/torch-practice

really clueless about it…
I am referencing ‘BinZhou’ s code

As the warning explains, your output and target do not have the same shape and thus will be broadcasted.
Make sure to pass both tensors as [batch_size, 1] to the criterion by unsqueezing the target via:

target = target.unsqueeze(1)

This might also fix the negative accuracy (although I don’t know, how you are calculating it).

PS: You can post code snippets by wrapping them into three backticks ```, which makes debugging easier. :wink: