'Compute derivative w.r.t input given derivative w.r.t output.'

def ComputeDeriv(self, state):

    if (self.activation == deepnet_pb2.Hyperparams.LOGISTIC):
        self.deriv.apply_logistic_deriv(state)
    elif (self.activation == deepnet_pb2.Hyperparams.TANH):
        self.deriv.apply_tanh_deriv(state)
        if self.hyperparams.dropout:
            self.deriv.mult(self.mask)
    elif (self.activation == deepnet_pb2.Hyperparams.RECTIFIED_LINEAR):
        self.deriv.apply_rectified_linear_deriv(state)
    elif (self.activation == deepnet_pb2.Hyperparams.RECTIFIED_LINEAR_SMOOTH):
        self.deriv.apply_rectified_linear_smooth_deriv(state)
    elif (self.activation == deepnet_pb2.Hyperparams.LINEAR):
        if self.hyperparams.dropout:
            self.deriv.mult(self.mask)
    elif (self.activation == deepnet_pb2.Hyperparams.SOFTMAX):
        raise Exception('Not    implemented.')
    else:
        raise Exception('Unknown    activation.')
