Skip to content

Commit bbfaf3c

Browse files
committed
linear2d_layer: make example converge
1 parent a97f141 commit bbfaf3c

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

example/linear2d.f90

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ program linear2d_example
55

66
type(network) :: net
77
real :: x(3, 4) = reshape( &
8-
[0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2], &
8+
[0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 0.11, 0.12, 0.13], &
99
[3, 4])
10-
real :: y(3) = [0.12, 0.1, 0.3]
11-
integer, parameter :: num_iterations = 5
10+
real :: y(3) = [0.12, 0.1, 0.2]
11+
integer, parameter :: num_iterations = 9
1212
integer :: n
1313

1414
net = network([ &
@@ -22,7 +22,7 @@ program linear2d_example
2222
do n = 1, num_iterations
2323
call net % forward(x)
2424
call net % backward(y, mse())
25-
call net % update(optimizer=sgd(learning_rate=1.))
25+
call net % update(optimizer=sgd(learning_rate=0.01))
2626
print '(i4,3(3x,f8.6))', n, net % predict(x)
2727
end do
2828

0 commit comments

Comments
 (0)