Custom cost function in deep learning toolbox
6 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I want to use a custom cost function in neural network that minimizes the mean square error between
. I followed the steps mentioned here:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/342568/image.png)
I created a file myfcn.m and +myfcn package.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/342571/image.png)
But when I run thte code with custom cost function
net.performFcn = 'myfcn'
I get the following error:
Error using network/subsasgn>network_subsasgn (line 555)
"performFcn" cannot be set to non-existing function "myfcn".
Error in network/subsasgn (line 14)
net = network_subsasgn(net,subscripts,v,netname);
Error in SDR_exp_customfcn (line 79)
net.performFcn = 'myfcn';
I couldn't figure out what the issue is.
0 comentarios
Respuestas (2)
Abbott Von
el 12 de Ag. de 2020
Well, maybe this tutorial can help you. The key is that line "Defining custom functions with this approach works only with the non-MEX version of the Neural Network code, so it is necessary to call 'train' using the 'nn7' option."
net = train(net,x,t,nn7);
y = net(x,nn7);
0 comentarios
Abbott Von
el 12 de Ag. de 2020
copyfile([matlabroot '\toolbox\nnet\nnet\nnperformance\mse.m'], 'myfcn.m');
copyfile([matlabroot '\toolbox\nnet\nnet\nnperformance\+mse'], '+myfcn');
And pull the necessary functions into your current working directories.
0 comentarios
Ver también
Categorías
Más información sobre Sequence and Numeric Feature Data Workflows en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!