print_image Subroutine

public subroutine print_image(images, labels, n)

Prints a single image and label to screen.

Arguments

Type IntentOptional AttributesName
real(kind=rk), intent(in) :: images(:,:)
real(kind=rk), intent(in) :: labels(:)
integer(kind=ik), intent(in) :: n

Contents

Source Code


Source Code

  subroutine print_image(images, labels, n)
    !! Prints a single image and label to screen.
    real(rk), intent(in) :: images(:,:), labels(:)
    integer(ik), intent(in) :: n
    real(rk) :: image(28, 28)
    character(len=1) :: char_image(28, 28)
    integer(ik) i, j
    image = reshape(images(:,n), [28, 28])
    char_image = '.'
    where (image > 0) char_image = '#'
    print *, labels(n)
    do j = 1, 28
      print *, char_image(:,j)
    end do
  end subroutine print_image