Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Matrix dimensions must agree -- error with old versions of Matlab #3

Closed
mahmoudnafifi opened this issue Mar 30, 2020 · 15 comments
Closed

Comments

@mahmoudnafifi
Copy link
Owner

mahmoudnafifi commented Mar 30, 2020

If you faced the following error in Matlab:

BE0A3C63@1D7A9B00 339B815E png

Please replace the lines 59 and 60 in WBmodel class and the lines 59 and 60 in WBmodel_GPU class with the following lines:
diff_u=abs(repmat(Iu,[1,size(A,2)])-repmat(A,[size(Iu,1),1]));
diff_v=abs(repmat(Iv,[1,size(A,2)])-repmat(A,[size(Iv,1),1]));

Please replace Line 69 in WBmodel.m and Line 69 in WBmodel_GPU.m with the following one:
hist(:,:,i)=(repmat(Iy, [1, size(diff_u,2)]) .* double(diff_u))'*double(diff_v);

Lastly, please replace line 92 in WBmodel.m and line 92 in WBmodel_GPU.m with the following code:
mf = sum(repmat(weightsH,[1, size(obj.mappingFuncs,2)]) .* obj.mappingFuncs(idH,:),1);

The old Matlab versions don't offer this broadcasting operation. In the new versions of Matlab, this repmat operation is automatically applied when the first/second operand is a single row vector and the second/first operand is a single column.

@wtzhu13
Copy link

wtzhu13 commented Jul 31, 2021

Hello, I have faced this error. But I can not run the demo.m because the model loaded does not replace. So how can I get the new model after replacing the line 59 and 60? Thank you!

@mahmoudnafifi
Copy link
Owner Author

What do you mean by "the model loaded does not replace"? Could you please explain more what is the error message you got in Matlab?

@mahmoudnafifi mahmoudnafifi reopened this Jul 31, 2021
@wtzhu13
Copy link

wtzhu13 commented Jul 31, 2021

I mean that I just replace the code, but the model loaded in the demo.h is still the old one.

@mahmoudnafifi
Copy link
Owner Author

Thanks for clarifying. No need to replace the model .. just replace the code and it should work.

@wtzhu13
Copy link

wtzhu13 commented Jul 31, 2021

really?Actually, I still can not run the demo.h. The model which is loaded in the demo in models folder is still the old one, I think maybe I should rebuild the model, but I can not find where to rebuild it. The version of my matlab is 2014a.
1

@mahmoudnafifi
Copy link
Owner Author

It seems that the problem is not in the model .. probably, it is related to the image itself. Do you mind to print out the size of Iy, diff_u and diff_v? Or if you can send me figure3.jpg. Thanks!

@wtzhu13
Copy link

wtzhu13 commented Aug 2, 2021

1
The size of the 3 variables are printed in the picture respectively, and the figure3.jpg is still the one which you pushed to the github, I do not repalce it.
figure3

@mahmoudnafifi
Copy link
Owner Author

mahmoudnafifi commented Aug 2, 2021

Please replace Line 69 in WBmodel.m and Line 69 in WBmodel_GPU.m with the following one:

hist(:,:,i)=(repmat(Iy, [1, size(diff_u,2)]) .* double(diff_u))'*double(diff_v); % compute the histogram

@wtzhu13
Copy link

wtzhu13 commented Aug 3, 2021

There are still some bugs in the code, but that's ok, I'll read your code and the paper carefully first so I don't waste your valuable time. I was going to see the phenomenon and then read the code and the paper carefully, but maybe I will deal with these bugs by myself after reading the paper and code. Thank you anyway!
1

@mahmoudnafifi
Copy link
Owner Author

Could you please refer to the part that you think it is a bug? What is the error message you got?

@wtzhu13
Copy link

wtzhu13 commented Aug 3, 2021

After replacing Line 69 in WBmodel.m and Line 69 in WBmodel_GPU.m, there are still some errors shown above.

@mahmoudnafifi
Copy link
Owner Author

thanks for sharing. I guess the problem is about broadcasting .. let me have a look and try to make things work for you.

@wtzhu13
Copy link

wtzhu13 commented Aug 3, 2021

OK,thank you for your guidance, I will also read the code carefully after my work.

@mahmoudnafifi
Copy link
Owner Author

Replace line 92 in WBmodel.m and line 92 in WBmodel_GPU.m with the following code:
mf = sum(repmat(weightsH,[1, size(obj.mappingFuncs,2)]) .* obj.mappingFuncs(idH,:),1);

Please let me know if you still have a problem with your Matlab version.

@wtzhu13
Copy link

wtzhu13 commented Aug 3, 2021

The code is running Ok, thanks for your guidance!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants