Exemplo n.º 1
0
 def sub_layer_layer_norm_residual_connection(
         self,
         layer_input,
         layer_output,
         layer_index,
         type,
         dropout_keep_prob=None,
         use_residual_conn=True):  # COMMON FUNCTION
     """
     layer norm & residual connection
     :param input: [batch_size,equence_length,d_model]
     :param output:[batch_size,sequence_length,d_model]
     :return:
     """
     print("@@@========================>layer_input:", layer_input,
           ";layer_output:", layer_output)
     #assert layer_input.get_shape().as_list()==layer_output.get_shape().as_list()
     #layer_output_new= layer_input+ layer_output
     layer_norm_residual_conn = LayerNormResidualConnection(
         layer_input,
         layer_output,
         layer_index,
         type,
         residual_dropout=(1 - dropout_keep_prob),
         use_residual_conn=use_residual_conn)
     output = layer_norm_residual_conn.layer_norm_residual_connection()
     return output  # [batch_size,sequence_length,d_model]
 def sub_layer_layer_norm_residual_connection(self,layer_input ,layer_output,layer_index,type,dropout_keep_prob=None,use_residual_conn=True): # COMMON FUNCTION
     """
     layer norm & residual connection
     :param input: [batch_size,equence_length,d_model]
     :param output:[batch_size,sequence_length,d_model]
     :return:
     """
     print("@@@========================>layer_input:",layer_input,";layer_output:",layer_output)
     #assert layer_input.get_shape().as_list()==layer_output.get_shape().as_list()
     #layer_output_new= layer_input+ layer_output
     layer_norm_residual_conn=LayerNormResidualConnection(layer_input,layer_output,layer_index,type,residual_dropout=(1-dropout_keep_prob),use_residual_conn=use_residual_conn)
     output = layer_norm_residual_conn.layer_norm_residual_connection()
     return output  # [batch_size,sequence_length,d_model]