(self,
max_seq_len=16,
njoints=None,
nfeats=None,
input_feats=None,
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,
use_final_proj=False,
output_var=False,
pos_embedding='sinusoidal',
init_cfg=None)
| 13 | class ACTOREncoder(BaseModule): |
| 14 | |
| 15 | def __init__(self, |
| 16 | max_seq_len=16, |
| 17 | njoints=None, |
| 18 | nfeats=None, |
| 19 | input_feats=None, |
| 20 | latent_dim=256, |
| 21 | condition_dim=None, |
| 22 | num_heads=4, |
| 23 | ff_size=1024, |
| 24 | num_layers=8, |
| 25 | activation='gelu', |
| 26 | dropout=0.1, |
| 27 | use_condition=False, |
| 28 | num_class=None, |
| 29 | use_final_proj=False, |
| 30 | output_var=False, |
| 31 | pos_embedding='sinusoidal', |
| 32 | init_cfg=None): |
| 33 | super().__init__(init_cfg=init_cfg) |
| 34 | self.njoints = njoints |
| 35 | self.nfeats = nfeats |
| 36 | if input_feats is None: |
| 37 | assert self.njoints is not None and self.nfeats is not None |
| 38 | self.input_feats = njoints * nfeats |
| 39 | else: |
| 40 | self.input_feats = input_feats |
| 41 | self.max_seq_len = max_seq_len |
| 42 | self.latent_dim = latent_dim |
| 43 | self.condition_dim = condition_dim |
| 44 | self.use_condition = use_condition |
| 45 | self.num_class = num_class |
| 46 | self.use_final_proj = use_final_proj |
| 47 | self.output_var = output_var |
| 48 | self.skelEmbedding = nn.Linear(self.input_feats, self.latent_dim) |
| 49 | if self.use_condition: |
| 50 | if num_class is None: |
| 51 | self.mu_layer = build_MLP(self.condition_dim, self.latent_dim) |
| 52 | if self.output_var: |
| 53 | self.sigma_layer = build_MLP(self.condition_dim, |
| 54 | self.latent_dim) |
| 55 | else: |
| 56 | self.mu_layer = nn.Parameter( |
| 57 | torch.randn(num_class, self.latent_dim)) |
| 58 | if self.output_var: |
| 59 | self.sigma_layer = nn.Parameter( |
| 60 | torch.randn(num_class, self.latent_dim)) |
| 61 | else: |
| 62 | if self.output_var: |
| 63 | self.query = nn.Parameter(torch.randn(2, self.latent_dim)) |
| 64 | else: |
| 65 | self.query = nn.Parameter(torch.randn(1, self.latent_dim)) |
| 66 | if pos_embedding == 'sinusoidal': |
| 67 | self.pos_encoder = SinusoidalPositionalEncoding( |
| 68 | latent_dim, dropout) |
| 69 | else: |
| 70 | self.pos_encoder = LearnedPositionalEncoding(latent_dim, |
| 71 | dropout, |
| 72 | max_len=max_seq_len + |
no test coverage detected