Initializes attention rnn states, decoder rnn states, attention weights, attention cumulative weights, attention context, stores memory and stores processed memory PARAMS ------ memory: Encoder outputs mask: Mask for padded data if training, expects N
(self, memory)
| 303 | return decoder_input |
| 304 | |
| 305 | def initialize_decoder_states(self, memory): |
| 306 | """ Initializes attention rnn states, decoder rnn states, attention |
| 307 | weights, attention cumulative weights, attention context, stores memory |
| 308 | and stores processed memory |
| 309 | PARAMS |
| 310 | ------ |
| 311 | memory: Encoder outputs |
| 312 | mask: Mask for padded data if training, expects None for inference |
| 313 | """ |
| 314 | B = memory.size(0) |
| 315 | MAX_TIME = memory.size(1) |
| 316 | dtype = memory.dtype |
| 317 | device = memory.device |
| 318 | |
| 319 | attention_hidden = torch.zeros( |
| 320 | B, self.attention_rnn_dim, dtype=dtype, device=device) |
| 321 | attention_cell = torch.zeros( |
| 322 | B, self.attention_rnn_dim, dtype=dtype, device=device) |
| 323 | |
| 324 | decoder_hidden = torch.zeros( |
| 325 | B, self.decoder_rnn_dim, dtype=dtype, device=device) |
| 326 | decoder_cell = torch.zeros( |
| 327 | B, self.decoder_rnn_dim, dtype=dtype, device=device) |
| 328 | |
| 329 | attention_weights = torch.zeros( |
| 330 | B, MAX_TIME, dtype=dtype, device=device) |
| 331 | attention_weights_cum = torch.zeros( |
| 332 | B, MAX_TIME, dtype=dtype, device=device) |
| 333 | attention_context = torch.zeros( |
| 334 | B, self.encoder_embedding_dim, dtype=dtype, device=device) |
| 335 | |
| 336 | processed_memory = self.attention_layer.memory_layer(memory) |
| 337 | |
| 338 | return (attention_hidden, attention_cell, decoder_hidden, |
| 339 | decoder_cell, attention_weights, attention_weights_cum, |
| 340 | attention_context, processed_memory) |
| 341 | |
| 342 | def parse_decoder_inputs(self, decoder_inputs): |
| 343 | """ Prepares decoder inputs, i.e. mel outputs |