mindspore.nn.CellList

class mindspore.nn.CellList(*args, **kwargs)[source]

Holds Cells in a list. For more details about Cell, please refer to Cell.

CellList can be used like a regular Python list, the Cells it contains have been initialized.

Parameters

args (list, optional) – List of subclass of Cell.

Supported Platforms:

Ascend GPU CPU

Examples

>>> import mindspore.nn as nn
>>>
>>> conv = nn.Conv2d(100, 20, 3)
>>> bn = nn.BatchNorm2d(20)
>>> relu = nn.ReLU()
>>> cell_ls = nn.CellList([bn])
>>> cell_ls.insert(0, conv)
>>> cell_ls.append(relu)
>>> cell_ls.extend([relu, relu])
append(cell)[source]

Appends a given Cell to the end of the list.

Parameters

cell (Cell) – The subcell to be appended.

extend(cells)[source]

Appends Cells from a Python iterable to the end of the list.

Parameters

cells (list) – The Cells to be extended.

Raises

TypeError – If the argument cells are not a list of Cells.

insert(index, cell)[source]

Inserts a given Cell before a given index in the list.

Parameters
  • index (int) – The Insert index in the CellList.

  • cell (Cell) – The Cell to be inserted.