Hi Friends , I’ve got a question , I’m working on CharSeqRnn. The code is as shown below , the non-overlapping sequence one:-

```
class CharSeqRnn(nn.Module):
def __init__(self, vocab_size, n_fac):
super().__init__()
self.e = nn.Embedding(vocab_size, n_fac)
self.rnn = nn.RNN(n_fac, n_hidden)
self.l_out = nn.Linear(n_hidden, vocab_size)
def forward(self, *cs):
bs = cs[0].size(0)
h = V(torch.zeros(1, bs, n_hidden))
inp = self.e(torch.stack(cs))
# print("Input size",inp.size())
outp,h = self.rnn(inp, h)
# print("Output size",self.l_out(outp[-1]).size())
return F.log_softmax(self.l_out(outp), dim=-1)
```

```
m = CharSeqRnn(vocab_size, n_fac).cuda()
opt = optim.Adam(m.parameters(), 1e-3)
it = iter(md.trn_dl)
*xst,yt = next(it)
t = m(*V(xst)); t.size()
```

Then the custom loss function:-

```
def nll_loss_seq(inp, targ):
sl,bs,nh = inp.size()
targ = targ.transpose(0,1).contiguous().view(-1)
return F.nll_loss(inp.view(-1,nh), targ)
fit(m, md, 4, opt, nll_loss_seq)
```

```
def get_next(inp):
idxs = T(np.array([char_indices[c] for c in inp]))
p = m(*VV(idxs))
i = np.argmax(to_np(p))
print(i)
return chars
```

When I’m using :-

```
(get_next('for thos'))
```

When I do `get_next('for thos')`

, Its showing all the 85 characters as output. How to get the next predicted character. I tried playing with the dimensions , but couldn’t get the desired next predicted output. . Any help is really appreciated.

The output that I get is shown in the snapshot below:-

Thanks,

Ashis