How do I impose a sparcity constraint when training a simple neural network?
조회 수: 1 (최근 30일)
이전 댓글 표시
I am training a feedforward network, and would like to know how response properties change when I add an additional constraint on the error function. Specifically, I want to give a cost to neural activation to enforce sparcity.
To be clear: I know what the maths is, but I don't know how to get it working in the Matlab implementation.
I have tried editing nncalc.perform, as described here (https://uk.mathworks.com/matlabcentral/answers/64319-neural-network-how-to-use-a-custom-performance-function) by changing the
e=gsubtract(t,y);
line, but it doesn't seem to work.
The neural net setup is very basic:
% example net settings
net=feedforwardnet([10 10 5]);
net.performFcn= 'mse';
net=init(net);
net.trainFcn = 'trainlm';
net.trainParam.epochs=100;
net.trainParam.showWindow = 0;
net.trainParam.max_fail=5;
% some sample training data:
x=[ 13 2 5 0 13 3 4 0;
6 15 12 0 6 16 13 0;
2 14 14 0 14 15 14 0;
5 4 11 0 5 5 11 0;
12 9 9 0 11 10 10 0];
R=[NaN NaN -0.0010;
NaN 0 NaN;
NaN 2.0000 NaN;
NaN NaN -0.0010;
-0.0010 NaN NaN];
net=train(net,x', R' );
Any help with this would be very much appreciated!
댓글 수: 0
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Deep Learning Toolbox에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!