import torch
import torch.nn as nn
# (batch_size, seq_len, hidden_size)
a = torch.randn(4, 512, 768)
a.shape # torch.Size([4, 512, 768])
fc = nn.Linear(768, 256)
b = fc(a)
b.shape # torch.Size([4, 512, 256])
备忘:----链接----
import torch
import torch.nn as nn
# (batch_size, seq_len, hidden_size)
a = torch.randn(4, 512, 768)
a.shape # torch.Size([4, 512, 768])
fc = nn.Linear(768, 256)
b = fc(a)
b.shape # torch.Size([4, 512, 256])
备忘:----链接----