Learning at the edge of chaos