Commit 23969bfe authored by Wolfgang Kilian's avatar Wolfgang Kilian
Browse files

Test für Anwendung auf Datenpunkt

parent 62b50b87
......@@ -12,6 +12,7 @@ module neurons
contains
procedure :: write
procedure :: init
procedure :: apply
end type neuron
contains
......@@ -40,4 +41,16 @@ contains
end subroutine init
function apply (n, x) result (z)
class(neuron), intent(in) :: n
real(wp), dimension(:), intent(in) :: x
real(wp) :: z
real(wp) :: y
y = n%a + dot_product (n%b, x)
z = tanh (y)
end function apply
end module neurons
......@@ -12,6 +12,8 @@ program nnet
call test_empty_neuron
write (u, *)
call test_init_neuron
write (u, *)
call test_apply_neuron
close (u)
......@@ -50,4 +52,22 @@ contains
end subroutine test_init_neuron
! Test: Neuron auf Datenpunkt angewendet
subroutine test_apply_neuron
use kinds, only: wp
use neurons, only: neuron
type(neuron) :: n
real(wp), dimension(2) :: x = [0.3_wp, 0.4_wp]
write (u, "(A)") "* Test: apply neuron to data"
call n%init (0.5_wp, [0.1_wp, 0.2_wp])
call n%write (u)
write (u, "(1x,A)") "Input:"
write (u, "(3x,A,*(1x,F11.9))") "x =", x
write (u, "(1x,A)") "Output:"
write (u, "(3x,A,*(1x,F11.9))") "z =", n%apply (x)
end subroutine test_apply_neuron
end program nnet
......@@ -10,3 +10,12 @@
Neuron:
a = 0.500000000
b = 0.100000000 0.200000000
* Test: apply neuron to data
Neuron:
a = 0.500000000
b = 0.100000000 0.200000000
Input:
x = 0.300000000 0.400000000
Output:
z = 0.544127099
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment