i am impementing random feedback alignment with sigmoidal activation function for the hidden layer.
(network is 2 layer model i.e 1 hidden layer)
I had to overide the backward method.
Is the code below correct?
@staticmethod
def backward(context, grad_output):
    input, weight, weight_rfa, bias = context.saved_variables
    grad_input= grad_weight = grad_weight_rfa = grad_bias = None
    
    if context.needs_input_grad[0]:
        grad_input = grad_output.mm(weight_rfa) 
                      
        
    if context.needs_input_grad[1]:
        grad_weight = grad_output.t().mm(input)

    if bias is not None and context.needs_input_grad[3]:
        grad_bias = grad_output.sum(0).squeeze(0)
        
    return grad_input, grad_weight, grad_weight_rfa, grad_bias