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. Unlike the SequentialCell, the cells in CellList are not connected.
- Parameters
args (list, optional) – List of subclass of Cell.
- Supported Platforms:
Ascend
GPU
CPU
Examples
>>> import mindspore as ms >>> import numpy as np >>> >>> conv = ms.nn.Conv2d(100, 20, 3) >>> bn = ms.nn.BatchNorm2d(20) >>> relu = ms.nn.ReLU() >>> cell_ls = ms.nn.CellList([bn]) >>> cell_ls.insert(0, conv) >>> cell_ls.append(relu) >>> cell_ls.extend([relu, relu]) >>> cell_ls_3 = cell_ls[3] >>> input1 = ms.Tensor(np.ones([2, 3]), ms.float32) >>> output = cell_ls_3(input1) >>> print(output) [[1. 1. 1.] [1. 1. 1.]]
- append(cell)[source]
Appends a given Cell to the end of the list.
- Parameters
cell (Cell) – The subcell to be appended.