A self-adaptive hardware with resistive switching synapses for experience-based neurocomputing