Effacer les filtres
Effacer les filtres

gradient descent for custom function

4 vues (au cours des 30 derniers jours)
L
L le 24 Avr 2024
Modifié(e) : Torsten le 24 Avr 2024
I have four equations:
1) e = m - y
2) y = W_3 * h
3) h = z + W_2 * z + f
4) f = W_1 * x
I want to update W_1, W_2 and W_3 in order to minimize a cost function J = (e^T e ) by using gradient descent.
x is an input, y is the output and m is the desired value for each sample in the dataset
I would like to do W_1 = W_1 - eta* grad(J)_w_1
W_2 = W_2 - eta* grad(J)_w_2
W_3 = W_3 - eta* grad(J)_w_3
Going through documentation I found out that you can train standard neural networks. But notice that I have some custom functions, so I guess it would be more of an optimization built in function to use.
Any ideas?
  2 commentaires
Matt J
Matt J le 24 Avr 2024
x is an input, y is the output and m is the desired value for each sample in the dataset
It looks like z is also an input. It is not given by any other equations.
L
L le 24 Avr 2024
Yes, z is another input.

Connectez-vous pour commenter.

Réponses (2)

Matt J
Matt J le 24 Avr 2024
Modifié(e) : Matt J le 24 Avr 2024
so I guess it would be more of an optimization built in function to use.
No, not necessarily. Your equations can be implemented with fullyConnectedLayers and additionLayers.
  3 commentaires
Matt J
Matt J le 24 Avr 2024
You would create a dlnetwork and then use trainnet.
L
L le 24 Avr 2024
Modifié(e) : L le 24 Avr 2024
Thanks @Matt J. I found the documentation hard to follow. I tried using the DL tool box, but I was only able to generate the topology. What should I do next ? how to train it on the x, z inputs? For each x,z input, I have a desired output m. For all matrices I don't wish to learn a bias term, so, in the tool box I set learnratebias =0

Connectez-vous pour commenter.


Torsten
Torsten le 24 Avr 2024
Déplacé(e) : Torsten le 24 Avr 2024
e = m - y = m - W_3*h = m - W_3*(z + W_2 * z + W_1 * x )
Now if you formulate this as
e = W1*z + W2*x - m
with
W1 = W_3 + W_2*W_3 and W2 = W_1*W_3
your problem is
min: || [z.',x.']*[W1;W2] - m ||_2
and you can use "lsqlin" to solve.
  10 commentaires
L
L le 24 Avr 2024
Well, I can prescribe some variables.
Torsten
Torsten le 24 Avr 2024
Modifié(e) : Torsten le 24 Avr 2024
As far as I understand, you have 10200 free parameters and 200 known values. I think you should re-consider your problem.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Sequence and Numeric Feature Data Workflows dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by