Looking for an Auto Differentiation package can be easily used as a function

2 ビュー (過去 30 日間)
Miraboreasu
Miraboreasu 2022 年 5 月 3 日
編集済み: Walter Roberson 2022 年 5 月 4 日
I construct a neural network in MATLAB using the basic array since I have no experience in the neural network toolbox. Now I need to take the derivative of all the parameters, like weight, bias, which are inside the activation function.
Is there any package (library) in MATLAB that can help me to do the auto differentiation without changing my basic data structure?
clc
clear
global stackw
stackw=1;
Ninput=2;
Noutput=2;
Nneuron=3; % each layer
Nlayers=3; % hidden layer
inputdata=ones(Ninput,1);
NNstruc=[];
NNstruc(1)=Ninput;
NNstruc(2:(Nlayers+1))=Nneuron;
NNstruc=[NNstruc,Noutput];
wsize=sum(NNstruc(1:(end-1)).*NNstruc(2:end));
bsize=Nlayers+1;
wset=rand(wsize,1);
bset=rand(bsize,1);
for i=1:(length(NNstruc)-1)
temp=NNtrack(inputdata, NNstruc, wset, i);
temp=logsig(temp+bset(i));
inputdata=temp;
end
function [output] = NNtrack(x, NNconfig, w, index)
global stackw;
x=x(:);
current=NNconfig(index);
next=NNconfig(index+1);
Nw=current*next;
Nb=next;
wtemp=reshape(w(stackw:(stackw+Nw-1)),[next current]);
stackw=stackw+Nw;
temp=wtemp*x;
output =wtemp*x;
end

回答 (1 件)

Walter Roberson
Walter Roberson 2022 年 5 月 3 日
編集済み: Walter Roberson 2022 年 5 月 4 日
No, the available package would require changes to your data structure.
  2 件のコメント
Torsten
Torsten 2022 年 5 月 3 日
So you don't lack theoretical knowledge about neural networks, but you want to gain knowledge on how to use the Neural Network Toolbox ? Then usually its documentation together with the examples provided is the best tutorial.

サインインしてコメントする。

カテゴリ

Find more on Deep Learning Toolbox in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by