(self,
max_seq_len=16,
njoints=None,
nfeats=None,
input_feats=None,
input_dim=256,
latent_dim=256,
condition_dim=None,
num_heads=4,
ff_size=1024,
num_layers=8,
activation='gelu',
dropout=0.1,
use_condition=False,
num_class=None,
pos_embedding='sinusoidal',
init_cfg=None)
| 129 | class ACTORDecoder(BaseModule): |
| 130 | |
| 131 | def __init__(self, |
| 132 | max_seq_len=16, |
| 133 | njoints=None, |
| 134 | nfeats=None, |
| 135 | input_feats=None, |
| 136 | input_dim=256, |
| 137 | latent_dim=256, |
| 138 | condition_dim=None, |
| 139 | num_heads=4, |
| 140 | ff_size=1024, |
| 141 | num_layers=8, |
| 142 | activation='gelu', |
| 143 | dropout=0.1, |
| 144 | use_condition=False, |
| 145 | num_class=None, |
| 146 | pos_embedding='sinusoidal', |
| 147 | init_cfg=None): |
| 148 | super().__init__(init_cfg=init_cfg) |
| 149 | if input_dim != latent_dim: |
| 150 | self.linear = nn.Linear(input_dim, latent_dim) |
| 151 | else: |
| 152 | self.linear = nn.Identity() |
| 153 | self.njoints = njoints |
| 154 | self.nfeats = nfeats |
| 155 | if input_feats is None: |
| 156 | assert self.njoints is not None and self.nfeats is not None |
| 157 | self.input_feats = njoints * nfeats |
| 158 | else: |
| 159 | self.input_feats = input_feats |
| 160 | self.max_seq_len = max_seq_len |
| 161 | self.input_dim = input_dim |
| 162 | self.latent_dim = latent_dim |
| 163 | self.condition_dim = condition_dim |
| 164 | self.use_condition = use_condition |
| 165 | self.num_class = num_class |
| 166 | if self.use_condition: |
| 167 | if num_class is None: |
| 168 | self.condition_bias = build_MLP(condition_dim, latent_dim) |
| 169 | else: |
| 170 | self.condition_bias = nn.Parameter( |
| 171 | torch.randn(num_class, latent_dim)) |
| 172 | if pos_embedding == 'sinusoidal': |
| 173 | self.pos_encoder = SinusoidalPositionalEncoding( |
| 174 | latent_dim, dropout) |
| 175 | else: |
| 176 | self.pos_encoder = LearnedPositionalEncoding(latent_dim, |
| 177 | dropout, |
| 178 | max_len=max_seq_len) |
| 179 | seqTransDecoderLayer = nn.TransformerDecoderLayer( |
| 180 | d_model=self.latent_dim, |
| 181 | nhead=num_heads, |
| 182 | dim_feedforward=ff_size, |
| 183 | dropout=dropout, |
| 184 | activation=activation) |
| 185 | self.seqTransDecoder = nn.TransformerDecoder(seqTransDecoderLayer, |
| 186 | num_layers=num_layers) |
| 187 | |
| 188 | self.final = nn.Linear(self.latent_dim, self.input_feats) |
nothing calls this directly
no test coverage detected