forked from mindspore-Ecosystem/mindspore
append and remove
This commit is contained in:
parent
4781021c1d
commit
777e624515
|
@ -19,6 +19,7 @@ from ..cell import Cell
|
|||
|
||||
__all__ = ['SequentialCell', 'CellList']
|
||||
|
||||
|
||||
def _valid_index(cell_num, index):
|
||||
if not isinstance(index, int):
|
||||
raise TypeError("Index {} is not int type")
|
||||
|
@ -145,6 +146,12 @@ class SequentialCell(Cell):
|
|||
for cell in self._cells.values():
|
||||
cell.set_grad(flag)
|
||||
|
||||
def append(self, cell):
|
||||
"""Appends a given cell to the end of the list."""
|
||||
if _valid_cell(cell):
|
||||
self._cells[str(len(self))] = cell
|
||||
return self
|
||||
|
||||
def construct(self, input_data):
|
||||
for cell in self.cell_list:
|
||||
input_data = cell(input_data)
|
||||
|
|
Loading…
Reference in New Issue