Effects of Ambient Sensing on SiOx-Based Resistive Switching and Resilience Modulation by Stacking Engineering