class_docstr: Just your regular densely-connected NN layer.
  `Dense` implements the operation:
  `output = activation(dot(input, kernel) + bias)`
  where `activation` is the element-wise activation function
  passed as the `activation` argument, `kernel` is a weights matrix
  created by the layer, and `bias` is a bias vector created by the layer
  (only applicable if `use_bias` is `True`).
  
  Arguments:
      units: Positive integer, dimensionality of the output space.
      activation: Activation function to use.
          If you don't specify anything, no activation is applied
          (ie. "linear" activation: `a(x) = x`).
      use_bias: Boolean, whether the layer uses a bias vector.
      kernel_initializer: Initializer for the `kernel` weights matrix.
      bias_initializer: Initializer for the bias vector.
      kernel_regularizer: Regularizer function applied to
          the `kernel` weights matrix.
      bias_regularizer: Regularizer function applied to the bias vector.
      activity_regularizer: Regularizer function applied to
          the output of the layer (its "activation").
      kernel_constraint: Constraint function applied to
          the `kernel` weights matrix.
      bias_constraint: Constraint function applied to the bias vector.
  
  Input shape:
      2D tensor with shape: `(batch_size, input_dim)`.
  
  Output shape:
      2D tensor with shape: `(batch_size, units)`.
class_docstr_tok: ["Just","your","regular","densely-connected","NN","layer",".","`","Dense","`","implements","the","operation",":","`","output","=","activation","(","dot","(","input",",","kernel",")","+","bias",")","`","where","`","activation","`","is","the","element-wise","activation","function","passed","as","the","`","activation","`","argument",",","`","kernel","`","is","a","weights","matrix","created","by","the","layer",",","and","`","bias","`","is","a","bias","vector","created","by","the","layer","(","only","applicable","if","`","use_bias","`","is","`","True","`",")",".","Arguments",":","units",":","Positive","integer",",","dimensionality","of","the","output","space",".","activation",":","Activation","function","to","use",".","If","you","do","n't","specify","anything",",","no","activation","is","applied","(","ie",".","``","linear","''","activation",":","`","a","(","x",")","=","x","`",")",".","use_bias",":","Boolean",",","whether","the","layer","uses","a","bias","vector",".","kernel_initializer",":","Initializer","for","the","`","kernel","`","weights","matrix",".","bias_initializer",":","Initializer","for","the","bias","vector",".","kernel_regularizer",":","Regularizer","function","applied","to","the","`","kernel","`","weights","matrix",".","bias_regularizer",":","Regularizer","function","applied","to","the","bias","vector",".","activity_regularizer",":","Regularizer","function","applied","to","the","output","of","the","layer","(","its","``","activation","''",")",".","kernel_constraint",":","Constraint","function","applied","to","the","`","kernel","`","weights","matrix",".","bias_constraint",":","Constraint","function","applied","to","the","bias","vector",".","Input","shape",":","2D","tensor","with","shape",":","`","(","batch_size",",","input_dim",")","`",".","Output","shape",":","2D","tensor","with","shape",":","`","(","batch_size",",","units",")","`","."]
docstr: dense backward
docstr_tok: ["dense","backward"]
code: def backward(self, d_y):
      """dense backward"""
      x = self._layer_input
      y = self._layer_output
      kernel = self.weights[0].read_value()
      grad_weights = []
      batch_size = int(x.shape[0])
  
      if self.activation_identifier is not None:
          self._activation_deriv = activations.get_deriv(
              self.activation_identifier
          )
          d_y = self._activation_deriv(y, d_y)
  
      d_x = tfe.matmul(d_y, kernel.transpose())
      d_weights = tfe.matmul(x.transpose(), d_y)
      if self.lazy_normalization:
          d_weights = d_weights / batch_size
      grad_weights.append(d_weights)
  
      if self.use_bias:
          d_bias = d_y.reduce_sum(axis=0)
          if self.lazy_normalization:
              d_bias = d_bias / batch_size
          grad_weights.append(d_bias)
  
      return grad_weights, d_x
  
file_path: tf-encrypted/tf_encrypted/keras/layers/dense.py
imports: from tensorflow.python.keras import initializers
  import tf_encrypted
  from tf_encrypted.keras import activations
  from tf_encrypted.keras.engine import Layer
  from tf_encrypted.keras.layers.layers_utils import default_args_check
label_desc: Use image node_id 5 for calling the Dense obj's underlying member method code with example usage: obj.backward(d_y) and returns: grad_weights,  d_x