Tile up the representations by `tile_factor`. Input - sequence of representations shape: (batch_size, seq_len, feature_dim) Output - sequence of tiled representations shape: (batch_size, seq_len * factor, feature_dim)
(self, feature)
| 115 | return s3prl_upstream, s3prl_featurizer |
| 116 | |
| 117 | def _tile_representations(self, feature): |
| 118 | """Tile up the representations by `tile_factor`. |
| 119 | Input - sequence of representations |
| 120 | shape: (batch_size, seq_len, feature_dim) |
| 121 | Output - sequence of tiled representations |
| 122 | shape: (batch_size, seq_len * factor, feature_dim) |
| 123 | """ |
| 124 | assert len(feature.shape) == 3, "Input argument `feature` has invalid shape: {}".format( |
| 125 | feature.shape |
| 126 | ) |
| 127 | tiled_feature = feature.repeat(1, 1, self.args.tile_factor) |
| 128 | tiled_feature = tiled_feature.reshape( |
| 129 | feature.size(0), feature.size(1) * self.args.tile_factor, feature.size(2) |
| 130 | ) |
| 131 | return tiled_feature |
| 132 | |
| 133 | def output_size(self) -> int: |
| 134 | """Output size.""" |