Saving Multiples Variable of a function

2 views (last 30 days)
I have some codes that i make
function result = back_prop(W1,W2,W3, A1,A2,A3, T_Input, Output)
dim_A = size(T_Input)
m = dim_A(2)
dZ3 = A3 - Output.'
dW3 = 1/m * dot_mult_dif_dim(dZ3, A2.')
db3 = 1/m * np_sum(dZ3)
dZ2 = dot_mult_dif_dim(W3.', dZ3).*(1 - A2.^2)
dW2 = 1/m * dot_mult_dif_dim(dZ2, A1.')
db2 = 1/m * np_sum(dZ2)
dZ1 = dot_mult_dif_dim(W2.', dZ2).*(1 - A1.^2)
dW1 = 1/m * dot_mult_dif_dim(dZ1, T_Input.')
db1 = 1/m * np_sum(dZ1)
end
where dot_mult_dif_dim and np_sum is a function that i make my own,
how can i save or access dZ3, dW3, db3, dZ2, dW2, db2, dZ1, dW1, and db1 ? each of them are matrix
i want to use them to update some parameters in NN, thank you
  1 Comment
yoel y
yoel y on 22 Oct 2020
for uppdating the parameters, it will be like this
W1 = W1 + αdW1
and it also apply for other variables

Sign in to comment.

Accepted Answer

Asad (Mehrzad) Khoddam
Asad (Mehrzad) Khoddam on 22 Oct 2020
If you want to use the variables in the other function, use this command in both functions:
global dZ3 dW3 db3 dZ2 dW2 db2 dZ1 dW1 db1

More Answers (0)

Categories

Find more on Sparse Matrices 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!