I get an error: AssertionError: embed_dim must be divisible by num_heads
(assert self.head_dim * num_heads == self.embed_dim, “embed_dim must be divisible by num_heads”)
I can’t understand how to fix it.
import torch
import torch.nn as nn

class Trans(nn.Module):
    def __init__(self, d_model=10):
        super().__init__()
        self.tr = nn.Transformer(d_model)
        
    def forward(self, src, tgt):
        out = self.tr(src, tgt)
        
        return out #output: (T, N, E)
    
net = Trans() 

sr = torch.randn(5, 1, 10) #src: (S, N, E)
tg = torch.randn(1, 1, 10) #tgt: (T, N, E)
outputs = net(sr, tg) 

print(outputs)