ToList

Description

Info

Parent class: Module

Derived classes: -

This module implements the function of eliminating list nesting.

Initializing

def __init__(self, name=None):

Parameters

Parameter Allowed types Description Default
name str Layer name None

Explanations

-

Examples

Necessary imports.

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

Info

gpuarray is required to properly place the tensor in the GPU

>>> data1 = gpuarray.to_gpu(np.random.randint(0, 9, (1, 1, 5)).astype(np.float32))
>>> data2 = gpuarray.to_gpu(np.random.randint(0, 9, (1, 1, 7)).astype(np.float32))
>>> data3 = gpuarray.to_gpu(np.random.randint(0, 9, (1, 1, 3)).astype(np.float32))
>>> data = [[data1, data2], data3]
>>> print(data)
[
 [[[[5. 8. 0. 5. 6.]]],
  [[[2. 2. 5. 8. 2. 7. 6.]]]],
 [[[1. 3. 4.]]]
]
>>> tolist = ToList()
>>> tolist(data)
[
  [[[5. 8. 0. 5. 6.]]],
  [[[2. 2. 5. 8. 2. 7. 6.]]],
  [[[1. 3. 4.]]]
]