This repository was archived by the owner on Jul 1, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -1009,6 +1009,25 @@ public struct AvgPool2D<Scalar: TensorFlowFloatingPoint>: Layer {
1009
1009
}
1010
1010
}
1011
1011
1012
+ /// A global average pooling layer for spatial data.
1013
+ @_fixed_layout
1014
+ public struct GlobalAveragePooling2D < Scalar: TensorFlowFloatingPoint > : Layer {
1015
+ /// Creates a global average pooling layer.
1016
+ public init ( ) { }
1017
+
1018
+ /// Returns the output obtained from applying the layer to the given input.
1019
+ ///
1020
+ /// - Parameters:
1021
+ /// - input: The input to the layer.
1022
+ /// - context: The contextual information for the layer application, e.g. the current learning
1023
+ /// phase.
1024
+ /// - Returns: The output.
1025
+ @differentiable
1026
+ public func applied( to input: Tensor < Scalar > , in _: Context ) -> Tensor < Scalar > {
1027
+ return input. mean ( alongAxes: [ 1 , 2 ] ) . reshaped ( to: [ input. shape [ 0 ] , input. shape [ 3 ] ] )
1028
+ }
1029
+ }
1030
+
1012
1031
/// A layer that applies layer normalization over a mini-batch of inputs.
1013
1032
///
1014
1033
/// Reference: [Layer Normalization](https://arxiv.org/abs/1607.06450).
You can’t perform that action at this time.
0 commit comments