KMaxPool

Description

Info

Parenr class: Module

Derived classes: -

K-Max Pooling is a pooling operation, which is a generalization of max-pooling by the time parameter used in the Max-TDNN model, which differs from the local max-pooling used in convolutional networks for object recognition (LeCun et al., 1998).

K-Max Pooling selects a subsequence out of the k maximum values of the sequence. This module implements a special case when the relative positions of the selected elements are not saved: the sorted values are returned to the output.

Initializing

def __init__(self, topk, axis, name=None):

Parameters

Parameters Allowed types Description Default
topk int Number of maximum values -
axis int Axis along which the operation is calculated -
name str Layer name None

Explanations

-

Examples

Necessary imports.

>>> import numpy as np
>>> from PuzzleLib.Backend import gpuarray
>>> from PuzzleLib.Modules import KMaxPool

Info

gpuarray is required to properly place the tensor in the GPU

>>> data = gpuarray.to_gpu(np.random.randint(0, 9, (1, 1, 10)).astype(np.float32))
>>> print(data)
[[[2. 0. 7. 5. 8. 3. 5. 0. 3. 0.]]]
>>> topk, axis = 2, 2
>>> kmaxpool = KMaxPool(topk=3, axis=2)
>>> kmaxpool(data)
[[[5. 7. 8.]]]