def prepare(args): idim = 10 odim = 5 model = E2E(idim, odim, args) batchsize = 2 x = torch.randn(batchsize, 10, idim) ilens = [10, 9] n_token = odim - 1 y_src = (torch.rand(batchsize, 4) * n_token % n_token).long() y_tgt = (torch.rand(batchsize, 4) * n_token % n_token).long() olens = [3, 4] for i in range(batchsize): x[i, ilens[i]:] = -1 y_tgt[i, olens[i]:] = model.ignore_id y_src[i, olens[i]:] = model.ignore_id data = [] for i in range(batchsize): data.append(( "utt%d" % i, { "input": [{ "shape": [ilens[i], idim] }], "output": [{ "shape": [olens[i]] }], }, )) return model, x, torch.tensor(ilens), y_tgt, y_src, data
def prepare(args): idim = 10 odim = 5 model = E2E(idim, odim, args) batchsize = 2 ilens = [10, 9] olens = [3, 4] n_token = odim - 1 x = torch.randn(batchsize, max(ilens), idim) y_src = (torch.rand(batchsize, max(olens)) * n_token % n_token).long() y_tgt = (torch.rand(batchsize, max(olens)) * n_token % n_token).long() for i in range(batchsize): x[i, ilens[i] :] = -1 y_tgt[i, olens[i] :] = model.ignore_id y_src[i, olens[i] :] = model.ignore_id data = {} uttid_list = [] for i in range(batchsize): data["utt%d" % i] = { "input": [{"shape": [ilens[i], idim]}], "output": [{"shape": [olens[i]]}], } uttid_list.append("utt%d" % i) return model, x, torch.tensor(ilens), y_tgt, y_src, data, uttid_list
def add_arguments(parser): """Add arguments.""" E2ETransformer.add_arguments(parser) E2E.add_conformer_arguments(parser) return parser