@@ -595,10 +595,6 @@ function (g::GlobalMaxPool)(x)
595
595
return maxpool (x, pdims)
596
596
end
597
597
598
- function Base. show (io:: IO , g:: GlobalMaxPool )
599
- print (io, " GlobalMaxPool()" )
600
- end
601
-
602
598
"""
603
599
GlobalMeanPool()
604
600
@@ -629,12 +625,8 @@ function (g::GlobalMeanPool)(x)
629
625
return meanpool (x, pdims)
630
626
end
631
627
632
- function Base. show (io:: IO , g:: GlobalMeanPool )
633
- print (io, " GlobalMeanPool()" )
634
- end
635
-
636
628
"""
637
- GlobalLPNormPool
629
+ GlobalLPNormPool(p::Float64)
638
630
639
631
Global lp norm pooling layer.
640
632
@@ -646,14 +638,14 @@ See also [`LPNormPool`](@ref).
646
638
```jldoctest
647
639
julia> xs = rand(Float32, 100, 100, 3, 50)
648
640
649
- julia> m = Chain(Conv((3,3), 3 => 7), GlobalLPNormPool())
641
+ julia> m = Chain(Conv((3,3), 3 => 7), GlobalLPNormPool(2.0 ))
650
642
651
643
julia> m(xs) |> size
652
644
(1, 1, 7, 50)
653
645
```
654
646
"""
655
647
struct GlobalLPNormPool
656
- p:: Number
648
+ p:: Float64
657
649
end
658
650
659
651
function (g:: GlobalLPNormPool )(x)
@@ -663,10 +655,6 @@ function (g::GlobalLPNormPool)(x)
663
655
return lpnormpool (x, pdims; p= g. p)
664
656
end
665
657
666
- function Base. show (io:: IO , g:: GlobalLPNormPool )
667
- print (io, " GlobalLPNormPool(p=" , g. p, " )" )
668
- end
669
-
670
658
"""
671
659
MaxPool(window::NTuple; pad=0, stride=window)
672
660
@@ -790,7 +778,7 @@ function Base.show(io::IO, m::MeanPool)
790
778
end
791
779
792
780
"""
793
- LPNormPool(window::NTuple, p::Number ; pad=0, stride=window)
781
+ LPNormPool(window::NTuple, p::Float64 ; pad=0, stride=window)
794
782
795
783
Lp norm pooling layer, calculating p-norm distance for each window,
796
784
also known as LPPool in pytorch.
@@ -802,14 +790,15 @@ By default the window size is also the stride in each dimension.
802
790
The keyword `pad` accepts the same options as for the `Conv` layer,
803
791
including `SamePad()`.
804
792
805
- See also [`Conv`](@ref), [`MaxPool`](@ref), [`GlobalLPNormPool`](@ref).
793
+ See also [`Conv`](@ref), [`MaxPool`](@ref), [`GlobalLPNormPool`](@ref),
794
+ [`pytorch LPPool`](https://pytorch.org/docs/stable/generated/torch.nn.LPPool2d.html).
806
795
807
796
# Examples
808
797
809
798
```jldoctest
810
799
julia> xs = rand(Float32, 100, 100, 3, 50);
811
800
812
- julia> m = Chain(Conv((5,5), 3 => 7), LPNormPool((5,5), 2; pad=SamePad()))
801
+ julia> m = Chain(Conv((5,5), 3 => 7), LPNormPool((5,5), 2.0 ; pad=SamePad()))
813
802
Chain(
814
803
Conv((5, 5), 3 => 7), # 532 parameters
815
804
LPNormPool((5, 5), p=2, pad=2),
@@ -821,7 +810,7 @@ julia> m[1](xs) |> size
821
810
julia> m(xs) |> size
822
811
(20, 20, 7, 50)
823
812
824
- julia> layer = LPNormPool((5,), 2, pad=2, stride=(3,)) # one-dimensional window
813
+ julia> layer = LPNormPool((5,), 2.0 , pad=2, stride=(3,)) # one-dimensional window
825
814
LPNormPool((5,), p=2, pad=2, stride=3)
826
815
827
816
julia> layer(rand(Float32, 100, 7, 50)) |> size
@@ -830,12 +819,12 @@ julia> layer(rand(Float32, 100, 7, 50)) |> size
830
819
"""
831
820
struct LPNormPool{N,M}
832
821
k:: NTuple{N,Int}
833
- p:: Number
822
+ p:: Float64
834
823
pad:: NTuple{M,Int}
835
824
stride:: NTuple{N,Int}
836
825
end
837
826
838
- function LPNormPool (k:: NTuple{N,Integer} , p:: Number ; pad = 0 , stride = k) where N
827
+ function LPNormPool (k:: NTuple{N,Integer} , p:: Float64 ; pad = 0 , stride = k) where N
839
828
stride = expand (Val (N), stride)
840
829
pad = calc_padding (LPNormPool, pad, k, 1 , stride)
841
830
return LPNormPool (k, p, pad, stride)
@@ -847,7 +836,7 @@ function (l::LPNormPool)(x)
847
836
end
848
837
849
838
function Base. show (io:: IO , l:: LPNormPool )
850
- print (io, " LPNormPool(" , l. k, " , p= " , l. p)
839
+ print (io, " LPNormPool(" , l. k, " , " , l. p)
851
840
all (== (0 ), l. pad) || print (io, " , pad=" , _maybetuple_string (l. pad))
852
841
l. stride == l. k || print (io, " , stride=" , _maybetuple_string (l. stride))
853
842
print (io, " )" )
0 commit comments