How to use polyfit instead of fit for fitting an exponential. For GPU processing.

조회 수: 80 (최근 30일)
Ok, I've been fighting this for way too long, and I've posed a similar question to this months ago, but I still do not get the values I so desparately need.
How do I use polyfit to get the 'b' value in the output from fit(X,Y,'exp1')?
I've taken the natural log of every combination of value, used polyval in various ways, and still get nothing within 5 orders of magnitude to what I need. I've read many different answers to this same question in the community, so if you post a link to one, I've probably seen it.
This would be moot if I could use fit with a GPU.
  댓글 수: 6
Matt J
Matt J 2019년 3월 13일
You can use gpuArray operations inside the objective function. In doing so, you can potentially gain speed advantages from your GPU.
It is probably a good idea for you to describe the structure of TE and SSS so we can better delve into how you would optimize the computation time. Are you looping over i,j and computing a separate pair [x1,x2] for each one? What are the dimensions of TE and SSS?
Walter Roberson
Walter Roberson 2019년 3월 13일
If i and j are both scalars, then you only need one squeeze() there instead of 2. You could also use
SS = reshape(SSS(i,j,:), [], 1);

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

답변 (1개)

Matt J
Matt J 2019년 3월 13일
편집: Matt J 2019년 3월 13일
For example,
a=1;
b=2;
x=gpuArray.linspace(0,2,100);
y=a*exp(b*x);
p=polyfit(x,log(y),1);
b_fit=p(1),
produces the desired value,
b_fit =
2
  댓글 수: 6
Kris Hoffman
Kris Hoffman 2019년 3월 13일
that startpoint is not absolutely necessary. I've tried it without as well and I get within 2% of the same fit.
I am much more concerned about this workaround to DRASTICALLY reduce processing time. Right now it takes 1.5hrs to process each data set on a quad core 3.1 GHz i7. If I run this through a supercomputer utilizing 48 xeon cores it takes 15 minutes. Now, theoretically, if I could pump this data through thousands of CUDA cores, it should be much faster than 15 minutes.
I NEED the b value from the exponential fit output OR if fit could be made to work with CUDA.
I have yet to find any solution that produces even the same sign (+/-) between the two methods.
Walter Roberson
Walter Roberson 2019년 3월 13일
polyfit runs on GPU.
If you are requiring 1.5 hours to do the fit() or polyfit then I would worry you would exceed the memory capacity of your GPU.

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

카테고리

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

제품


릴리스

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by