Efficient and self-adaptive in-situ learning in multilayer memristor neural networks