tf.layers.PoolerLayerV2 module
tf.layers.PoolerLayerV2 module¶
- class tf.layers.PoolerLayerV2.PoolerLayerV2(*args: Any, **kwargs: Any)¶
Bases:
modelzoo.common.tf.layers.BaseLayer.BaseLayer
The pooler layer. Usually used for pooling or summarizing the sequence data.
This layer is added as a workaround to the existing pooler layer for additional masking support. The plan is to use this layer for kernel matching and integ bring up. After we have full support for this layer, we should deprecate the old
PoolerLayer
.- Parameters
pooler_type (str) – Type of pooling. Currently supports the following
types (pooler) –
"mean"
: Mean reduction."max"
: Max reduction."first"
: First slice in the axis dimension."last"
: Last slice in the axis dimension (Not yet supported)"sum"
: Takes the sum over the axis dimension. Defaults to the entire Tensor.
axis (int) – The dimensions to reduce. If None (the default), reduces all dimensions.
boundary_casting (bool) – If
True
, outputs the values in half precision and casts the input values up to full precision.tf_summary (bool) – If
True
, saves the activations withsummary_layer
.
- call(inputs, padding_mask=None)¶
Apply pooling with optional masking.
- Parameters
inputs (Tensor) – Input tensor.
padding_mask (Tensor) – The padding mask tensor. Assumed to be 1-based, i.e., has
1
in the non-padded positions and0
elsewhere. If the input tensor is of the shape[d0, d1, ..., d_{k-1}, d_{axis}, d_{k+1}, ... d_n]
, then thepadding_mask
must have the shape[d0, d1, ..., d_{k-1}, axis]
or[d0, d1, ..., d_{k-1}, axis, 1, ..., 1]
. IfNone
(the default), a padding mask of all 1’s is used.