  Surface ion traps are among the most promising technologies for scaling up
quantum computing machines, but their complicated multi-electrode geometry can
make some tasks, including compensation for stray electric fields, challenging
both at the level of modeling and of practical implementation. Here we
demonstrate the compensation of stray electric fields using a gradient descent
algorithm and a machine learning technique, which trained a deep learning
network. We show automated dynamical compensation tested against induced
electric charging from UV laser light hitting the chip trap surface. The
results show improvement in compensation using gradient descent and the machine
learner over manual compensation. This improvement is inferred from an increase
of the fluorescence rate of 78% and 96% respectively, for a trapped
$^{171}$Yb$^+$ ion driven by a laser tuned to -7.8 MHz of the
$^2$S$_{1/2}\leftrightarrow^2$P$_{1/2}$ Doppler cooling transition at 369.5 nm.
