Generate HDL code from SVM function in Matlab.

I'm having Matlab 9.0.0.341360 (R2016a), I need to generate HDL code from SVM function in Matlab. Please help. Thanks.

답변 (2개)

Tim McBrayer
Tim McBrayer 2017년 10월 18일
편집: Tim McBrayer 2017년 10월 18일

0 개 추천

The R2016a list of built-in MATLAB functions supported for HDL code generation can be found at https://www.mathworks.com/help/releases/R2016a/hdlcoder/ug/functions-supported-for-hdl-code-generation-alphabetical-list.html .

댓글 수: 3

Thanks for reply! However, as long as I don't see Support Vector Machine (SVM) in the list, does it mean that there is no other ways, or workarounds, please?
Tim McBrayer
Tim McBrayer 2017년 10월 19일
I don't know what SVM is or does, or how complex it is. There is always the option to create your own MATLAB implementation, using supported functions. Such user-written code should be valid for HDL code generation.
Hi Tim, SVM stands for "Support Vector Machine", it's a machine learning algorithm.

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

Brian Ogilvie
Brian Ogilvie 2017년 10월 23일

0 개 추천

Hi Mohamed,
The SVM function or ClassificationSVM object are not directly supported for HDL code generation but you can build your own version fairly easily. We had some internal projects that an intern worked on that involved an SVM for a size 36 feature vector that classified A-Z and 0-9. I can share the code that was created as a starting point for you. You will need to supply your trained Beta and Bias values plus decide on the data types that you need for your algorithm. This can generate a lot of logic and we were not able to fit much more than a detector and classifier for one digit in the smaller FPGA we were using at the time. Obviously, this is not production-ready code and just represents a starting point.
function y = fcn(u)
%#codegen
Beta = zeros(36,1);
Bias = zeros(36,1);
lin_u = zeros(36,1);
% Real Beta and Bias values from training set here
for ii=1:1:36
lin_u(ii) = Beta(ii).*u(ii) + Bias(ii);
end
f_neg = -lin_u;
f = 1-lin_u;
f(f<0) = 0;
f_neg = 1-f_neg;
f_neg(f_neg<0) = 0;
%%Function to perform easy sum
k=0;cnt1=1;
cn1=zeros(36,36-1);
for i36=36-1:-1:1
k=k+1;
for j=1:1:i36
cn1(k,j)=f(1,cnt1);
cnt1=cnt1+1;
end
end
cnt2=1;
for a36=36-1:-1:1
for b36=1:1:a36
cn1(36-a36+b36,a36)=f_neg(1,cnt2);
cnt2=cnt2+1;
end
end
y_tmp=zeros(36,1);
for i=1:1:36
y_tmp(i)=sum(cn1(i,:));
end
y = y_tmp(1); % the value of interest

카테고리

도움말 센터File Exchange에서 Code Generation에 대해 자세히 알아보기

질문:

2017년 10월 18일

댓글:

2017년 10월 24일

Community Treasure Hunt

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

Start Hunting!

Translated by