I am working on a character-level multiclass problem and want to know if there are any good sites that explain how to code GRUs for this sort of thing, or if anyone can share the code for it. Here is my code for a LSTM version:
#basic model, need to modify to situation
class NLP_model(nn.Module):
def init(self, vocab_size, embedding_dim, hidden_dim, num_classes):
super(NLP_model, self).init()
self.char_embedding = nn.Embedding(vocab_size, embedding_dim)
self.lstm = nn.LSTM(embedding_dim, hidden_dim, num_layers = 5, bidirectional= True)
self.fc = nn.Linear(hidden_dim*2,num_classes)
#self.att = nn.MultiheadAttention(embed_dim, num_heads, …)
def forward(self, x):
    x = self.char_embedding(x)
    output, hidden = self.lstm(x)
    hidden = torch.cat((hidden[0][-2,:,:], hidden[0][-1,:,:]), dim=1)
    x = self.fc(hidden[0])

    return x

What would a GRU version of this code look like? How do I learn how to code NLP? There’s tons of articles about what GRU is, but I have a hard time finding code tutorials explaining a GRU through code.