Gradient descent: Difference between revisions
m
→{{header|Perl 6}}
SqrtNegInf (talk | contribs) (Added Perl example) |
|||
Line 209:
# Calculate initial norm.
my $b = $alpha / (my $delG =
while ( $delG > $tolerance ) { # Iterate until value is <= tolerance.
Line 221 ⟶ 219:
# Calculate next norm.
$b = $alpha / ($delG =
my $g1 = g(@x); # Calculate next value.
Line 232 ⟶ 228:
sub gradG(@x, $h) { # Provides a rough calculation of gradient g(x).
▲ for ^N { @y[$_] += $h ; @z[$_] = (g(@y) - $g0) / $h }
}
|