Skip to content

Instantly share code, notes, and snippets.

@ChunML
Created April 29, 2019 07:59
Show Gist options
  • Save ChunML/e91d764e5bfd2574352157e3d7b0235c to your computer and use it in GitHub Desktop.
Save ChunML/e91d764e5bfd2574352157e3d7b0235c to your computer and use it in GitHub Desktop.
def call(self, sequence):
embed_out = self.embedding(sequence)
embed_out += pes[:sequence.shape[1], :]
sub_in = embed_out
for i in range(self.num_layers):
sub_out = self.attention[i](sub_in, sub_in)
sub_out = sub_in + sub_out
sub_out = self.attention_norm[i](sub_out)
ffn_in = sub_out
ffn_out = self.dense_2[i](self.dense_1[i](ffn_in))
ffn_out = ffn_in + ffn_out
ffn_out = self.ffn_norm[i](ffn_out)
sub_in = ffn_out
return ffn_out
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment