Improving the accuracy and robustness of RRAM-based in-memory computing against RRAM hardware noise and adversarial attacks