/
githubmirror
/
MockingBird
Обзор
Документация
Войти
/
githubmirror
/
MockingBird
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
models/ppg_extractor/encoder/repeat.py
30 строк
676 B
babysor00
Refactor Project to 3 parts: Models, Control, Data
03 дек 2022, 11:54
03 дек 2022, 11:54
74a3fc9
Код
Авторство
О чём код?
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # Copyright 2019 Shigeki Karita # Apache 2.0 (http://www.apache.org/licenses/LICENSE-2.0) """Repeat the same layer definition.""" import torch class MultiSequential(torch.nn.Sequential): """Multi-input multi-output torch.nn.Sequential.""" def forward(self, *args): """Repeat.""" for m in self: args = m(*args) return args def repeat(N, fn): """Repeat module N times. :param int N: repeat time :param function fn: function to generate module :return: repeated modules :rtype: MultiSequential """ return MultiSequential(*[fn(n) for n in range(N)])