'Update the parameters associated with this edge.
Update the weights and associated parameters.
Args:
deriv: Gradient w.r.t the inputs at the outgoing end.
step: Training step.'

def UpdateEdgeParams(self, edge, deriv, step):

    numcases = edge.node1.batchsize
    if (edge.conv or edge.local):
        ConvOuter(edge, edge.temp)
        edge.gradient.add_mult(edge.temp, mult=(1.0 / numcases))
    else:
        edge.gradient.add_dot(edge.node1.state, deriv.T, mult=(1.0 / numcases))
    if edge.tied_to:
        edge.tied_to.gradient.add(edge.gradient)
        edge.gradient.assign(0)
        edge = edge.tied_to
    edge.num_grads_received += 1
    if (edge.num_grads_received == edge.num_shares):
        edge.Update('weight', step)
