Initialise 2D dropblock layer
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(dropblock2d_layer_type), | intent(inout) | :: | this |
Instance of the 2D dropblock layer |
||
| integer, | intent(in), | dimension(:) | :: | input_shape |
Input shape |
|
| integer, | intent(in), | optional | :: | verbose |
Verbosity level |
subroutine init_dropblock2d(this, input_shape, verbose) !! Initialise 2D dropblock layer implicit none ! Arguments class(dropblock2d_layer_type), intent(inout) :: this !! Instance of the 2D dropblock layer integer, dimension(:), intent(in) :: input_shape !! Input shape integer, optional, intent(in) :: verbose !! Verbosity level ! Local variables integer :: verbose_ = 0 !! Verbosity level !--------------------------------------------------------------------------- ! Initialise optional arguments !--------------------------------------------------------------------------- if(present(verbose)) verbose_ = verbose !--------------------------------------------------------------------------- ! Initialise input shape !--------------------------------------------------------------------------- if(.not.allocated(this%input_shape)) call this%set_shape(input_shape) !--------------------------------------------------------------------------- ! Set up number of channels, width, height !--------------------------------------------------------------------------- this%num_channels = this%input_shape(3) allocate(this%output_shape(2)) this%output_shape = this%input_shape !--------------------------------------------------------------------------- ! Set gamma !--------------------------------------------------------------------------- ! original paper uses keep_prob, we use drop_rate ! drop_rate = 1 - keep_prob this%gamma = ( this%rate/this%block_size**2._real32 ) * & this%input_shape(1) / & (this%input_shape(1) - this%block_size + 1._real32) * & this%input_shape(2) / & (this%input_shape(2) - this%block_size + 1._real32) allocate(this%mask( & this%input_shape(1), & this%input_shape(2)), source=.true.) !--------------------------------------------------------------------------- ! Generate mask !--------------------------------------------------------------------------- call this%generate_mask() !--------------------------------------------------------------------------- ! Allocate arrays !--------------------------------------------------------------------------- if(this%use_graph_input)then call stop_program( & "Graph input not supported for 2D dropblock layer" & ) return end if if(allocated(this%output)) deallocate(this%output) allocate( this%output(1,1) ) end subroutine init_dropblock2d