@@ -828,73 +828,23 @@ public struct MaxPool2D<Scalar: TensorFlowFloatingPoint>: Layer {
828
828
/// - poolSize: Vertical and horizontal factors by which to downscale.
829
829
/// - strides: The strides.
830
830
/// - padding: The padding.
831
- self. init( poolSize: ( 1 , poolSize. 0 , poolSize. 1 , 1 ) ,
832
- strides: ( 1 , strides. 0 , strides. 1 , 1 ) ,
833
- padding: padding)
834
-
835
- /// Returns the output obtained from applying the layer to the given input.
836
- ///
837
- /// - Parameter input: The input to the layer.
838
- /// - Returns: The output.
839
- @differentiable
840
- public func call( _ input: Tensor < Scalar > ) -> Tensor < Scalar > {
841
- return input. maxPooled (
842
- kernelSize: poolSize, strides: strides, padding: padding)
843
- }
844
- }
845
-
846
- /// A max pooling layer for spatial or spatio-temporal data.
847
- @_fixed_layout
848
- public struct MaxPool3D < Scalar: TensorFlowFloatingPoint > : Layer {
849
- /// The size of the sliding reduction window for pooling.
850
- @noDerivative let poolSize : ( Int , Int , Int , Int , Int )
851
- /// The strides of the sliding window for each dimension of a 5-D input.
852
- /// Strides in non-spatial dimensions must be `1`.
853
- @noDerivative let strides : ( Int , Int , Int , Int , Int )
854
- /// The padding algorithm for pooling.
855
- @noDerivative let padding : Padding
856
-
857
- /// Creates a max pooling layer.
858
- public init (
859
- poolSize: ( Int , Int , Int , Int , Int ) ,
860
- strides: ( Int , Int , Int , Int , Int ) ,
861
- padding: Padding
862
- ) {
863
- self . poolSize = poolSize
864
- self . strides = strides
831
+ public init ( poolSize: ( Int , Int ) , strides: ( Int , Int ) , padding: Padding = . valid) {
832
+ self . poolSize = ( 1 , poolSize. 0 , poolSize. 1 , 1 )
833
+ self . strides = ( 1 , strides. 0 , strides. 1 , 1 )
865
834
self . padding = padding
866
835
}
867
836
868
- /// Creates a max pooling layer.
869
- ///
870
- /// - Parameters:
871
- /// - poolSize: Vertical and horizontal factors by which to downscale.
872
- /// - strides: The strides.
873
- /// - padding: The padding.
874
- self. init( poolSize: ( 1 , poolSize. 0 , poolSize. 1 , poolSize. 2 , 1 ) ,
875
- strides: ( 1 , strides. 0 , strides. 1 , strides. 2 , 1 ) ,
876
- padding: padding)
877
-
878
837
/// Returns the output obtained from applying the layer to the given input.
879
838
///
880
839
/// - Parameter input: The input to the layer.
881
840
/// - Returns: The output.
882
841
@differentiable
883
842
public func call( _ input: Tensor < Scalar > ) -> Tensor < Scalar > {
884
- return input. maxPooled ( kernelSize: poolSize, strides: strides, padding: padding)
843
+ return input. maxPooled (
844
+ kernelSize: poolSize, strides: strides, padding: padding)
885
845
}
886
846
}
887
847
888
- public extension MaxPool3D {
889
- /// Creates a max pooling layer with the specified pooling window size and stride. All
890
- /// pooling sizes and strides are the same.
891
- init ( poolSize: Int , stride: Int , padding: Padding = . valid) {
892
- self . init ( poolsize: ( poolSize, poolSize, poolSize) ,
893
- strides: ( stride, stride, stride) ,
894
- padding: padding)
895
- }
896
- }
897
-
898
848
/// An average pooling layer for temporal data.
899
849
@_fixed_layout
900
850
public struct AvgPool1D < Scalar: TensorFlowFloatingPoint > : Layer {
@@ -944,7 +894,7 @@ public struct AvgPool2D<Scalar: TensorFlowFloatingPoint>: Layer {
944
894
/// The padding algorithm for pooling.
945
895
@noDerivative let padding : Padding
946
896
947
- /// Creates an average pooling layer.
897
+ /// Creates a average pooling layer.
948
898
public init (
949
899
poolSize: ( Int , Int , Int , Int ) ,
950
900
strides: ( Int , Int , Int , Int ) ,
@@ -955,58 +905,18 @@ public struct AvgPool2D<Scalar: TensorFlowFloatingPoint>: Layer {
955
905
self . padding = padding
956
906
}
957
907
958
- /// Creates an average pooling layer.
908
+ /// Creates a average pooling layer.
959
909
///
960
910
/// - Parameters:
961
911
/// - poolSize: Vertical and horizontal factors by which to downscale.
962
912
/// - strides: The strides.
963
913
/// - padding: The padding.
964
- self. init( poolSize: ( 1 , poolSize. 0 , poolSize. 1 , 1 ) ,
965
- strides: ( 1 , strides. 0 , strides. 1 , 1 ) ,
966
- padding: padding)
967
-
968
- /// Returns the output obtained from applying the layer to the given input.
969
- ///
970
- /// - Parameter input: The input to the layer.
971
- /// - Returns: The output.
972
- @differentiable
973
- public func call( _ input: Tensor < Scalar > ) -> Tensor < Scalar > {
974
- return input. averagePooled ( kernelSize: poolSize, strides: strides, padding: padding)
975
- }
976
- }
977
-
978
- /// An average pooling layer for spatial or spatio-temporal data.
979
- @_fixed_layout
980
- public struct AvgPool3D < Scalar: TensorFlowFloatingPoint > : Layer {
981
- /// The size of the sliding reduction window for pooling.
982
- @noDerivative let poolSize : ( Int , Int , Int , Int , Int )
983
- /// The strides of the sliding window for each dimension of a 5-D input.
984
- /// Strides in non-spatial dimensions must be `1`.
985
- @noDerivative let strides : ( Int , Int , Int , Int , Int )
986
- /// The padding algorithm for pooling.
987
- @noDerivative let padding : Padding
988
-
989
- /// Creates an average pooling layer.
990
- public init (
991
- poolSize: ( Int , Int , Int , Int , Int ) ,
992
- strides: ( Int , Int , Int , Int , Int ) ,
993
- padding: Padding
994
- ) {
995
- self . poolSize = poolSize
996
- self . strides = strides
914
+ public init ( poolSize: ( Int , Int ) , strides: ( Int , Int ) , padding: Padding = . valid) {
915
+ self . poolSize = ( 1 , poolSize. 0 , poolSize. 1 , 1 )
916
+ self . strides = ( 1 , strides. 0 , strides. 1 , 1 )
997
917
self . padding = padding
998
918
}
999
919
1000
- /// Creates an average pooling layer.
1001
- ///
1002
- /// - Parameters:
1003
- /// - poolSize: Vertical and horizontal factors by which to downscale.
1004
- /// - strides: The strides.
1005
- /// - padding: The padding.
1006
- self. init( poolSize: ( 1 , poolSize. 0 , poolSize. 1 , poolSize. 2 , 1 ) ,
1007
- strides: ( 1 , strides. 0 , strides. 1 , strides. 2 , 1 ) ,
1008
- padding: padding)
1009
-
1010
920
/// Returns the output obtained from applying the layer to the given input.
1011
921
///
1012
922
/// - Parameter input: The input to the layer.
@@ -1017,15 +927,6 @@ public struct AvgPool3D<Scalar: TensorFlowFloatingPoint>: Layer {
1017
927
}
1018
928
}
1019
929
1020
- public extension AvgPool3D {
1021
- /// Creates an average pooling layer with the specified pooling window size and stride. All
1022
- /// pooling sizes and strides are the same.
1023
- init ( poolSize: Int , strides: Int , padding: Padding = . valid) {
1024
- self . init ( poolSize: ( poolSize, poolSize, poolSize) ,
1025
- strides: ( strides, strides, strides) ,
1026
- padding: padding)
1027
- }
1028
- }
1029
930
1030
931
/// A global average pooling layer for temporal data.
1031
932
@_fixed_layout
0 commit comments