Integral with neural network

조회 수: 2 (최근 30일)
Steven Ramsey
Steven Ramsey 2017년 8월 18일
댓글: Carsten Daldrup 2020년 9월 23일
I am trying to use the integral function with a neural network. Specifically, I set up the following:
func = @(c,x) net([c x]');
When I try to then use:
integral(@(c)func(c,sometable{1,3:end}),0,Inf)
I get the following error:
Error using network/sim (line 266) Input data sizes do not match net.inputs{1}.size.
Error in network/subsref (line 15) otherwise, v = sim(vin,subs{:});
Error in @(c,x)net([c,x]')
Error in @(c)func(c,oro_data{j,3:end})
Error in integralCalc/iterateScalarValued (line 314) fx = FUN(t);
Error in integralCalc/vadapt (line 132) [q,errbnd] = iterateScalarValued(u,tinterval,pathlen);
Error in integralCalc (line 83) [q,errbnd] = vadapt(@AToInfInvTransform,interval);
Error in integral (line 88) Q = integralCalc(fun,a,b,opstruct);
However, if I just evaluate
func(c,sometable{1,3:end})
It works fine, so it does not seem to be an input data size issue there. Any suggestions or insights as to what is happening and if it is resolvable?
Thanks.
  댓글 수: 1
Carsten Daldrup
Carsten Daldrup 2020년 9월 23일
Hi Steven,
how do you edit/prepare your data for this network? Does is it work for any function oder do you have to train it every time again?
Do you have some good advice oder documentation?
Thanks,
Carsten

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

답변 (2개)

Nate
Nate 2017년 8월 22일
편집: Nate 2017년 8월 22일
Hi Steven,
I would be happy to look into this if you could post your full code to reproduce the issue. You can attach the files to your post.
Thanks,
Nate
  댓글 수: 1
Steven Ramsey
Steven Ramsey 2017년 8월 23일
Hi Nate,
I have since changed the code and just hard coded the neural net output as a workaround. I've attached some code which should be a close approximation to what I originally attempted. Matlab is currently running the new code so I wasn't able to test it, but I imagine it'll reproduce the result. It seems the integral function does not like matrices or matrix operations. Even using the element-wise operations I could not get it to work, so my workaround uses every input and network weight individually. It's not overly onerous, but it's not ideal, as I have multiple network structures with differing number of hidden-layer nodes, so I have to adjust the function for each specification.
Thanks,
Steve

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


Greg Heath
Greg Heath 2017년 8월 24일
Whenever I have to use a NN inside another function, I find it MUCH easier to just use the matrix format
y = net(IW,LW,B1,B2,x) = B2 + LW * ( B1 + IW * x);
Hope this helps.
Thank you for formally accepting my answer
Greg

카테고리

Help CenterFile Exchange에서 Deep Learning Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by