Function for Prediction of a self_organizing_map
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(self_organizing_map) | :: | kohonen_map |
A |
|||
type(kohonen_pattern), | intent(inout), | dimension(:) | :: | input_data |
A |
|
integer, | intent(out), | dimension(:,:) | :: | map_output |
An integer array with the map output |
Type | Visibility | Attributes | Name | Initial | |||
---|---|---|---|---|---|---|---|
integer, | public | :: | ipattern | ||||
integer, | public | :: | ihit | ||||
integer, | public | :: | jhit | ||||
integer, | public | :: | khit | ||||
integer, | public | :: | ix | ||||
integer, | public | :: | iy | ||||
integer, | public | :: | iz | ||||
integer, | public | :: | number_variables | ||||
integer, | public | :: | i | ||||
integer, | public | :: | j | ||||
integer, | public | :: | k | ||||
real(kind=wp), | public | :: | dist_hit | ||||
real(kind=wp), | public | :: | dist | ||||
type(kohonen_prototype), | public | :: | current_prototype | ||||
real(kind=wp), | public, | dimension(kohonen_map%parameters%number_variables1, kohonen_map%parameters%number_variables2) | :: | current_values |
subroutine predict_som(kohonen_map,input_data,map_output) !======================================================================================== !! Function for Prediction of a self_organizing_map class(self_organizing_map) :: kohonen_map !! A `self_organizing_map` object type(kohonen_pattern),dimension(:),intent(inout) :: input_data !! A `kohonen_pattern` array with the input data integer,dimension(:,:),intent(out) :: map_output !! An integer array with the map output integer :: ipattern,ihit,jhit,khit,ix,iy,iz,number_variables,i,j,k real(kind=wp) :: dist_hit,dist type(kohonen_prototype) :: current_prototype real(kind=wp),dimension(kohonen_map%parameters%number_variables1,& kohonen_map%parameters%number_variables2) :: current_values ! number_variables=kohonen_map%parameters%number_variables1*& kohonen_map%parameters%number_variables2; ! ! write(*,*) 'SOM: Prediction starting...'; ! write(*,*) number_variables do ipattern = 1, size(input_data,1) ihit = 0; jhit = 0; dist_hit = 100000.0_wp; call input_data(ipattern)%get(current_prototype); !call current_prototype%print(); !write(*,*) ihit,jhit,dist_hit !call current_prototype%get_prototype(current_values); !$OMP parallel do do iz=1,size(kohonen_map%grid,3) do iy = 1, size(kohonen_map%grid,2); do ix = 1, size(kohonen_map%grid,1); dist = 0.0_wp; !write(*,*) ix,iy,dist !call kohonen_map%grid(ix,iy)%print(); dist=kohonen_map%grid(ix,iy,iz)%distance(current_prototype,& kohonen_map%distance_function); dist = dist/float(number_variables); if (dist < dist_hit) then dist_hit = dist; ihit = ix; jhit = iy; khit = iz; endif enddo enddo enddo ! !$OMP end parallel do ! call kohonen_map%grid(ihit,jhit,khit)%get_prototype(current_values); ! if(size(current_values,2) .eq. 1) then ! write(kohonen_map%parameters%iout,*) (current_values(i,1),& ! i=1,size(current_values,1)); ! else ! do i=1,size(current_values,1) ! write(kohonen_map%parameters%iout,*) (current_values(i,j),j=1,& ! size(current_values,2)) ! enddo ! endif !call map_output(ipattern)%create(current_values); map_output(ipattern,1)=ihit; map_output(ipattern,2)=jhit; map_output(ipattern,3)=khit; !size(current_values,1),size(current_values,2) !write(*,*) current_values enddo !ipattern ! write(*,*) 'SOM: Prediction finished'; ! end subroutine predict_som