필터 지우기
필터 지우기

error in the code not getting removed

조회 수: 1 (최근 30일)
tejasvee
tejasvee 2017년 4월 14일
댓글: tejasvee 2017년 4월 18일
Hello Experts, I have code in which it gives error of "Error of inner matrix dimension". i have checked many of answers in the group asked by others and tried but it is not getting removed. Help me to remove this error.If i comment that line of code it runs.Error is not in "main.m" program but it is in "trainRELM.m" line no 87. While i run the main.m it gives error Error using * Inner matrix dimensions must agree.
Error in trainRELM (line 87)
w = (H'*H+l1*eye(nh,nh))\(H'*Data.y);
is main cause of error
Error in Main (line 47)
LR2 = trainRELM(DataTG,Params);
I have attached the code and dataset.

채택된 답변

dpb
dpb 2017년 4월 14일
You have two matrix multiplications in the offending line H+l1*eye(nh,nh))\(H'*Data.y);
So, the problem is one of the following:
  1. Variable i1 is a not square(*), or
  2. size(H',2) ~= size(Data.y,1)(*), or
  3. didn't intend to use matrix multiplication but element-wise which is the "dot" operator ".*"
Don't know which of the above is the actual case nor necessarily the answer you need as didn't try to read the code but looking through your algorithm for the intended result ensuring that you can actually perform a legal matrix multiplication if that's what is wanted or if it is computation in the numerator/denominator of the expression that is supposed to be element-by-element, then fix the operator to do that instead.
() Matrix multiplication requires A*B have dimensions such that are [m x n][n x q] with result of [m x q].
  댓글 수: 7
tejasvee
tejasvee 2017년 4월 17일
Thankyou Sir for reply, I figured out that there is error in inner matrix dimension due to (H'*Data.y); in the below equation as H' is of dimension 100*303 and Data.y is of 0. i checked the size of Data.y w = (H'*H+l1*eye(nh,nh))\(H'*Data.y); But i can't understand how to make it of dimension 303*n as Data.y is is the vector of labels, either regression or classification labels (+1,-1) then how it could be of dimension 303*n or something else.
tejasvee
tejasvee 2017년 4월 18일
Sir in the last query , i asked you for data.y is not compatible for matrix multiplication. As it is vector of labels, either regression or classification labels (+1,-1) so i converted it to matrix by using Data.y=vec2mat(Data.y,297) to make it compatible but again there is same error of inner matrix dimension. What should i do to make it compatible. https://in.mathworks.com/matlabcentral/answers/335348-error-in-the-code-not-getting-removed

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by