Last active
February 7, 2017 20:32
-
-
Save Shoeboxam/66f00cfbc809b453ea1c41d8b85ed207 to your computer and use it in GitHub Desktop.
Functional erf minimization with scalar theta
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
environment = [4, 5, 7, 8]; | |
expectation = 23; | |
% Initial weight | |
theta = 0.5; | |
theta_old = theta - 0.25; | |
while abs(theta - theta_old) > 1e-12 | |
% Derivative of squared error: ln = (expectation - reinforcement)^2 | |
dln_dr = -2 * (expectation - theta * environment); | |
% By chain rule: r = theta * environment | |
dr_dw = transpose(environment); % env is a column vector | |
dln_dw = dln_dr * dr_dw; | |
% Save old theta so one can check for difference | |
theta_old = theta; | |
% Substitute derivatives into theta update | |
theta = theta - 0.001 * (dln_dw); % 1xn * nx1 | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'm commenting so I can check it on my computer lol