original_docstring: 
      Parameters
      ----------
      x: Input data 2D tensor
      w: Weight 2D tensor
      s_in: 1D tensor with scaling factors of the input activations
      Returns
      -------
      2D tensor with output activations
      Max activation in the layer
      1D tensor with output scaling factors
      
docstring: Parameters
  x: Input data 2D tensor
  w: Weight 2D tensor
  s_in: 1D tensor with scaling factors of the input activations
  Returns
  
  2D tensor with output activations
  Max activation in the layer
  1D tensor with output scaling factors
docstring_tokens: Parameters x : Input data 2D tensor w : Weight 2D tensor s_in : 1D tensor with scaling factors of the input activations Returns 2D tensor with output activations Max activation in the layer 1D tensor with output scaling factors
code: def sc_matmul(x, w, s_in, upscale=False, gain=None):
      """
      Parameters
      ----------
      x: Input data 2D tensor
      w: Weight 2D tensor
      s_in: 1D tensor with scaling factors of the input activations
      Returns
      -------
      2D tensor with output activations
      Max activation in the layer
      1D tensor with output scaling factors
      """
  
      # Bring all the activations under a common scaling factor
      max_scale = tf.reduce_max(s_in)
  
      rescale_ratio = tf.div(s_in, max_scale, name="mydiv1")
      x_rescaled = tf.multiply(x, rescale_ratio)
  
      # Calculate the down-scale coefficients in terms of the weights
      s = tf.reduce_sum(tf.abs(w), axis=0)
      S = tf.reshape(tf.tile(s, [tf.shape(x)[0]]),
                     shape=[tf.shape(x)[0], tf.shape(w)[1]])
  
      # Matrix mutiplication using re-scaled feature data
      y = tf.matmul(x_rescaled, w)
      z = tf.div(y, S, name="mydiv2")
  
      curr_scale = tf.multiply(max_scale, S)
  
      # Apply gain followed by saturation
      if (upscale):
          z_upscaled = tf.multiply(z, gain)
          #MUTATION#
          new_scale = tf.div(curr_scale, gain, name="mydiv3")
      else:
          z_upscaled = z
          new_scale = curr_scale
  
      out_scale = new_scale[0, :]
      max_act = tf.reduce_max(z_upscaled)
  
      z_clipped = tf.clip_by_value(z_upscaled, -1, +1)
  
      return z_clipped, max_act, out_scale
code_tokens: def sc_matmul ( x , w , s_in , upscale = False , gain = None ) : max_scale = tf . reduce_max ( s_in ) rescale_ratio = tf . div ( s_in , max_scale , name = "mydiv1" ) x_rescaled = tf . multiply ( x , rescale_ratio ) s = tf . reduce_sum ( tf . abs ( w ) , axis = 0 ) S = tf . reshape ( tf . tile ( s , [ tf . shape ( x ) [ 0 ] ] ) , shape = [ tf . shape ( x ) [ 0 ] , tf . shape ( w ) [ 1 ] ] ) y = tf . matmul ( x_rescaled , w ) z = tf . div ( y , S , name = "mydiv2" ) curr_scale = tf . multiply ( max_scale , S ) if ( upscale ) : z_upscaled = tf . multiply ( z , gain ) new_scale = tf . div ( curr_scale , gain , name = "mydiv3" ) else : z_upscaled = z new_scale = curr_scale out_scale = new_scale [ 0 , : ] max_act = tf . reduce_max ( z_upscaled ) z_clipped = tf . clip_by_value ( z_upscaled , - 1 , + 1 ) return z_clipped , max_act , out_scale
short_docstring: Parameters
  x: Input data 2D tensor
  w: Weight 2D tensor
  s_in: 1D tensor with scaling factors of the input activations
  Returns
short_docstring_tokens: Parameters x : Input data 2D tensor w : Weight 2D tensor s_in : 1D tensor with scaling factors of the input activations Returns
comment: """
      Parameters
      ----------
      x: Input data 2D tensor
      w: Weight 2D tensor
      s_in: 1D tensor with scaling factors of the input activations
      Returns
      -------
      2D tensor with output activations
      Max activation in the layer
      1D tensor with output scaling factors
      """$SEP$# Bring all the activations under a common scaling factor$SEP$# Calculate the down-scale coefficients in terms of the weights$SEP$# Matrix mutiplication using re-scaled feature data$SEP$# Apply gain followed by saturation$SEP$#MUTATION#