- Navigate to the folder containing the NN transfer functions (MATLAB\R2017a\toolbox\nnet\nnet\nntransfer in Windows)
- Copy the file "tansig.m" and the directory "+tansig".
- Paste the copied file and directory into your working directory
- Modify the name of "tansig.m" and "+tansig" to reflect the new transfer function name, for example "myFcn.m" and "+myFcn".
- Modify the code in the relevant files of "+myFcn"to properly calculate the new transfer function and its derivative.
- For the layer in the neural network that will use this transfer function, change the "transferFcn" property to 'myFcn'.
How to define a custom transferFcn for recurrent neural network ?
26 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Dear all,
I'm currently using Recurrent Neural Networks (layrecnet), and I am trying to use a custom transfer function, in order to try a "Leaky ReLU" approach. I read some topics discussing way to add custom transfer functions (or performance functions) :
https://fr.mathworks.com/matlabcentral/answers/118968-how-to-create-custom-transfer-function-for-neural-network-in-matlab
https://fr.mathworks.com/matlabcentral/answers/56137-how-to-use-a-custom-transfer-function-in-neural-net-training
And I did this :
- Went into my folder .../MATLAB/R2018b/toolbox/nnet/nnet/nntransfer/
- I copied poslin.m (as reference) and pasted it as "lkposlin.m"
- In "lkposlin.m", I replaced both "poslin" with "lkposlin"
- I copied the folder "+poslin" and pasted it as "+lkposlin"
- All the permissions are the same as default files
I did not make any other changes, just to try it out. And then, when I called in my network using "net.layers{1}.transferFcn='lkposlin'", my code sends me error an error saying "lkposlin" is an unknown function or variable. What am I missing ?
0 comentarios
Respuestas (2)
Vijaya Lakshmi Chagi
el 14 de Mzo. de 2019
Hi Nicolas,
The function files and packages to use for defining custom versions of other Neural Network components can be found by executing the following in MATLAB:
doc nncustom
For custom transfer functions, would recommend you to use +tansig package as reference.
Hope the information helps you.
2 comentarios
Illia
el 8 de Nov. de 2022
For those who's googling: new files should be either copied to a working directory (where your script is placed), or the directory should be placed to path (see path function). nntransfer folder is not initially on path (at least in my case).
a1a1 b1b1
el 26 de Jun. de 2019
hello dear nicolas
i had your problem too . i find solution of that and send it here .
to solve this problem you should copy and paste your mfile (myfunction.m) and the respective folder (+myfunction) to current directory (current folder) of your matlab codes;
i hope this become helpful.
thanks
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!