activation_m.f90 Source File


Files dependent on this one

sourcefile~~activation_m.f90~~AfferentGraph sourcefile~activation_m.f90 activation_m.f90 sourcefile~activation_s.f90 activation_s.F90 sourcefile~activation_s.f90->sourcefile~activation_m.f90 sourcefile~neural_network_m.f90 neural_network_m.f90 sourcefile~neural_network_m.f90->sourcefile~activation_m.f90 sourcefile~training_configuration_m.f90 training_configuration_m.f90 sourcefile~training_configuration_m.f90->sourcefile~activation_m.f90 sourcefile~training_configuration_s.f90 training_configuration_s.F90 sourcefile~training_configuration_s.f90->sourcefile~activation_m.f90 sourcefile~training_configuration_s.f90->sourcefile~training_configuration_m.f90 sourcefile~fiats_m.f90 fiats_m.f90 sourcefile~fiats_m.f90->sourcefile~neural_network_m.f90 sourcefile~fiats_m.f90->sourcefile~training_configuration_m.f90 sourcefile~trainable_network_m.f90 trainable_network_m.f90 sourcefile~fiats_m.f90->sourcefile~trainable_network_m.f90 sourcefile~layer_m.f90 layer_m.f90 sourcefile~layer_m.f90->sourcefile~neural_network_m.f90 sourcefile~neural_network_s.f90 neural_network_s.F90 sourcefile~neural_network_s.f90->sourcefile~neural_network_m.f90 sourcefile~neural_network_s.f90->sourcefile~layer_m.f90 sourcefile~trainable_network_m.f90->sourcefile~neural_network_m.f90 sourcefile~trainable_network_m.f90->sourcefile~training_configuration_m.f90 sourcefile~unmapped_network_s.f90 unmapped_network_s.F90 sourcefile~unmapped_network_s.f90->sourcefile~neural_network_m.f90 sourcefile~workspace_s.f90 workspace_s.F90 sourcefile~workspace_s.f90->sourcefile~neural_network_m.f90 sourcefile~concurrent-inferences.f90 concurrent-inferences.f90 sourcefile~concurrent-inferences.f90->sourcefile~fiats_m.f90 sourcefile~layer_s.f90 layer_s.F90 sourcefile~layer_s.f90->sourcefile~layer_m.f90 sourcefile~learn-addition.f90 learn-addition.F90 sourcefile~learn-addition.f90->sourcefile~fiats_m.f90 sourcefile~learn-exponentiation.f90 learn-exponentiation.F90 sourcefile~learn-exponentiation.f90->sourcefile~fiats_m.f90 sourcefile~learn-multiplication.f90 learn-multiplication.F90 sourcefile~learn-multiplication.f90->sourcefile~fiats_m.f90 sourcefile~learn-power-series.f90 learn-power-series.F90 sourcefile~learn-power-series.f90->sourcefile~fiats_m.f90 sourcefile~learn-saturated-mixing-ratio.f90 learn-saturated-mixing-ratio.F90 sourcefile~learn-saturated-mixing-ratio.f90->sourcefile~fiats_m.f90 sourcefile~saturated_mixing_ratio_m.f90 saturated_mixing_ratio_m.f90 sourcefile~learn-saturated-mixing-ratio.f90->sourcefile~saturated_mixing_ratio_m.f90 sourcefile~print-training-configuration.f90 print-training-configuration.F90 sourcefile~print-training-configuration.f90->sourcefile~fiats_m.f90 sourcefile~read-query-infer.f90 read-query-infer.f90 sourcefile~read-query-infer.f90->sourcefile~fiats_m.f90 sourcefile~saturated_mixing_ratio_m.f90->sourcefile~fiats_m.f90 sourcefile~train-and-write.f90 train-and-write.F90 sourcefile~train-and-write.f90->sourcefile~fiats_m.f90 sourcefile~trainable_network_s.f90 trainable_network_s.f90 sourcefile~trainable_network_s.f90->sourcefile~trainable_network_m.f90 sourcefile~write-read-infer.f90 write-read-infer.F90 sourcefile~write-read-infer.f90->sourcefile~fiats_m.f90

Source Code

! Copyright (c), The Regents of the University of California
! Terms of use are as specified in LICENSE.txt

module activation_m
  use iso_c_binding, only :  c_int
  use julienne_m, only : string_t
  implicit none

  private
  public :: activation_t
  public :: gelu, relu, sigmoid, step, swish

  enum, bind(C)
    enumerator :: gelu=1, relu, sigmoid, step, swish
  end enum

  character(len=*), parameter :: activation_name(*) =  [character(len("sigmoid")) :: "gelu", "relu", "sigmoid", "step", "swish"]

  type activation_t
    private
    integer(c_int) :: selection_ = sigmoid
  contains
    procedure, non_overridable :: function_name
    generic :: operator(==) => equals
    procedure, private      :: equals
    generic :: evaluate                 => default_real_evaluate     , double_precision_evaluate
    procedure, non_overridable, private :: default_real_evaluate     , double_precision_evaluate
    generic :: differentiate            => default_real_differentiate, double_precision_differentiate
    procedure, non_overridable, private :: default_real_differentiate, double_precision_differentiate
  end type

  interface activation_t

    elemental module function construct_from_component(selection) result(activation)
      implicit none
      integer(c_int), intent(in) :: selection
      type(activation_t) activation
    end function
    
    elemental module function construct_from_name(name) result(activation)
      implicit none
      character(len=*), intent(in) :: name
      type(activation_t) activation
    end function

  end interface

  interface

    elemental module function equals(self, rhs) result(self_eq_rhs)
      implicit none
      class(activation_t), intent(in) :: self
      type(activation_t), intent(in) :: rhs
      logical self_eq_rhs
    end function

    elemental module function default_real_evaluate(self, x) result(y)
      implicit none
      class(activation_t), intent(in) :: self
      real, intent(in) :: x 
      real y 
    end function

    elemental module function double_precision_evaluate(self, x) result(y)
      implicit none
      class(activation_t), intent(in) :: self
      double precision, intent(in) :: x 
      double precision y 
    end function 

    elemental module function default_real_differentiate(self, x) result(dy_dx)
      implicit none
      class(activation_t), intent(in) :: self
      real, intent(in) :: x 
      real dy_dx 
    end function

    elemental module function double_precision_differentiate(self, x) result(dy_dx)
      implicit none
      class(activation_t), intent(in) :: self
      double precision, intent(in) :: x 
      double precision dy_dx 
    end function

    elemental module function function_name(self) result(string)
      implicit none
      class(activation_t), intent(in) :: self
      type(string_t) string
    end function

  end interface

end module activation_m