Maybe this is a simple question, but why do we need to define the encoder layers like this
self.enc_layers = [EncoderLayer(embedding_dim=self.embedding_dim,
num_heads=num_heads,
fully_connected_dim=fully_connected_dim,
dropout_rate=dropout_rate,
layernorm_eps=layernorm_eps)
for _ in range(self.num_layers)]
and then call it by this
for i in range(self.num_layers):
x = self.enc_layers[i](x,training, mask)
Can we define it like this:
self.enc_layer = EncoderLayer(embedding_dim=self.embedding_dim,
num_heads=num_heads,
fully_connected_dim=fully_connected_dim,
dropout_rate=dropout_rate,
layernorm_eps=layernorm_eps)
and then call it like this
for i in range(self.num_layer):
x = self.enc_layer(x,training, mask)