Toward Understanding In-context vs. In-weight Learning