Hi i am trying to implement a RNN to learn number pattern.Here is the code. When i run it i encounter the following error.Help!!!
for i in range(1000):
    inp=torch.randn(1,1)
    y=torch.randn(1,1)
    
    
    ht=torch.tanh(whh.mm(ht_1)+wxt.mm(inp.float()))
    y_pred=why.mm(ht)
    

    
    loss=(y_pred-y.float()).pow(2).sum()
    loss.backward(retain_graph=True)
    
    
    
    with torch.no_grad():
        whh-=lr*whh.grad
        wxt-=lr*wxt.grad
        why-=lr*why.grad
        whh.grad.zero_()
        wxt.grad.zero_()
        why.grad.zero_()
        ht_1=ht
    print(loss)