Subroutine to assign input to clusters
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(two_level_self_organizing_map) | :: | kohonen_map |
A |
|||
type(kohonen_pattern), | intent(inout), | dimension(:) | :: | input_patterns |
A |
Type | Visibility | Attributes | Name | Initial | |||
---|---|---|---|---|---|---|---|
type(kohonen_prototype), | public | :: | current_prototype | ||||
type(kohonen_prototype), | public | :: | current_prototype1 | ||||
integer, | public | :: | ipattern | ||||
integer, | public | :: | ic | ||||
integer, | public | :: | i_hit | ||||
integer, | public | :: | current_pos | ||||
real(kind=wp), | public | :: | dist_min | ||||
real(kind=wp), | public | :: | dist |
subroutine assign_input_to_clusters(kohonen_map,input_patterns) !======================================================================================== !! Subroutine to assign input to clusters class(two_level_self_organizing_map) :: kohonen_map !! A `two_level_self_organizing_map` object type(kohonen_pattern),dimension(:),intent(inout) :: input_patterns !! A `kohonen_pattern` array type(kohonen_prototype) :: current_prototype,current_prototype1 integer :: ipattern,ic,i_hit,current_pos real(kind=wp) :: dist_min,dist ! ! write(*,*) 'assign= ',size(input_patterns) do ipattern=1,kohonen_map%parameters(1)%number_patterns call input_patterns(ipattern)%get(current_prototype); ! write(*,*) 'ipat= ',ipattern dist_min=1.0d5; do ic=1,size(kohonen_map%cluster_layer) current_prototype1=kohonen_map%cluster_layer(ic) dist=current_prototype1%distance(current_prototype,kohonen_map%distance_function); if(dist < dist_min) then i_hit=ic; dist_min=dist; ! write(*,*) 'ic= ',ipattern,i_hit endif enddo kohonen_map%number_cluster_samples(i_hit)=kohonen_map%number_cluster_samples(i_hit)+1; current_pos=kohonen_map%number_cluster_samples(i_hit); ! write(*,*)' ic,pos= ',ic,i_hit,current_pos,allocated(kohonen_map%number_cluster_samples),& ! size(kohonen_map%number_cluster_samples) ! write(*,*) kohonen_map%number_cluster_samples kohonen_map%index_cluster_samples(i_hit,current_pos)=ipattern; enddo!ipattern1 ! ! do ic=1,size(kohonen_map%cluster_layer) ! write(*,*) ic,kohonen_map%number_cluster_samples(ic),(kohonen_map%index_cluster_samples(ic,1:5)) ! enddo ! end subroutine assign_input_to_clusters