Happy new years

This commit is contained in:
Sen Liang committed 2022-02-07 17:28:40 +08:00
1 parent c7175dd7ff
commit 8c4865effb
53 files changed
+4604 -61

No files matched your search

+40
View File
@@ -0,0 +1,40 @@
import torch
import torch.nn as nn
from common.debug import debug
class Audio2MotionHead(nn.Module):
def __init__(self, opt):
super(Audio2MotionHead, self).__init__()
self.opt = opt
self.dim_motion = opt.MODEL.dim_motion # 53
self.dim_speech = opt.MODEL.dim_speech # 27
print(f"dim_speech={self.dim_speech}")
# encoder
self.head = nn.Sequential( # nbatch x nseqlen x 27
nn.Linear(in_features=self.dim_speech, out_features=256),
nn.LeakyReLU(0.2),
nn.Linear(in_features=256, out_features=self.dim_motion),
nn.Tanh()
)
def forward(self, x):
""" forward function
Args:
x: torch.Tensor, [nbatch x seqlen x dim_condit]
return:
pred: torch.Tensor, [nbatch x seqlen x dim_motion]
"""
debug(self.opt, f"[forward] input x shape = {x.shape}", verbose=False)
pred = self.head(x) # [nbatch x nseqlen x dim_hidden]
debug(self.opt, f"[forward] decoder shape = {pred.shape}", verbose=False)
return pred