mindspore/docs/api/api_python/nn/mindspore.nn.SequentialCell...

30 lines
1.1 KiB
ReStructuredText
Raw Normal View History

2021-12-07 17:19:19 +08:00
mindspore.nn.SequentialCell
============================
.. py:class:: mindspore.nn.SequentialCell(*args)
构造Cell顺序容器。关于Cell的介绍可参考 `Cell <https://www.mindspore.cn/docs/zh-CN/master/api_python/nn/mindspore.nn.Cell.html#mindspore.nn.Cell>`_
2021-12-07 17:19:19 +08:00
2022-01-10 23:31:01 +08:00
SequentialCell将按照传入List的顺序依次将Cell添加。此外也支持OrderedDict作为构造器传入。
.. note:: SequentialCell 和 torch.nn.ModuleList 是不同的ModuleList是一个用于存储模块的列表但SequentialCell中的Cell是以级联方式连接的不是单纯的存储。
2021-12-07 17:19:19 +08:00
参数:
- **args** (list, OrderedDict) - 仅包含Cell子类的列表或有序字典。
2021-12-07 17:19:19 +08:00
输入:
- **x** (Tensor) - Tensor其shape取决于序列中的第一个Cell。
2021-12-07 17:19:19 +08:00
输出:
Tensor输出Tensor其shape取决于输入 `x` 和定义的Cell序列。
2021-12-08 10:01:50 +08:00
异常:
- **TypeError** - `args` 的类型不是列表或有序字典。
2021-12-07 17:19:19 +08:00
2021-12-08 10:01:50 +08:00
.. py:method:: append(cell)
2021-12-07 17:19:19 +08:00
2022-01-10 23:31:01 +08:00
在容器末尾添加一个Cell。
2021-12-07 17:19:19 +08:00
参数:
- **cell** (Cell) - 要添加的Cell。