Flatten

Description

Info

Parent class: Module

Derived classes: -

This module performs the straightening (flattening): a tensor of shape (N, d_1, ..., d_k) is collapsed into one of shape (N, \displaystyle\prod_{i=1}^{k}d_i).

Initializing

def __init__(self, name=None):

Parameters

Parameter Allowed types Description default
name str Имя слоя. None

Explanations

-

Examples

Necessary imports.

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

Info

gpuarray is required to properly place the tensor in the GPU.

>>> data = gpuarray.to_gpu(np.random.randn(10, 2, 32, 32).astype(np.float32))
>>> data.shape
(10, 2, 32, 32)
>>> flatten = Flatten()
>>> data = flatten(data)
>>> data.shape
(10, 2048)