That looks great! But does the code work? You have that # -- WRONG CODE -- comment, and it indeed looks incorrect to me. You can’t construct an optimizer with a single Variable input. It needs a list of Variables, so optim.Adam([input], lr = 0.01) should work.