## 1 Introduction  
Confocal microscopy (CM) is frequently used in life sciences to investigate biological samples, such as tissues and cells, where high spatial resolution is necessary to obtain information about small structures of the sample. The main advantage of CM is the optical sectioning capability, introduced by a confocally aligned pinhole [1, 2]. However, CM is a point-wise measurement technique and thus scans in three dimensions are required to acquire three-dimensional information. To accomplish an axial scan, several methods are known. In stage scanning, the sample is moved through the constant focus by a stage as introduced in [3], though motion artefacts in the scan may occur. Another commercially available possibility for axial scanning is a piezo-driven objective holder [4]. Alternatively, deformable mirrors (DM) may also be used for axial scanning [5] and aberration correction [6, 7]. In recent years, another general approach based on adaptive lenses (AL) was introduced [2, 8, 9, 10]. By tuning the voltage applied to the AL, the focus shifts axially without the need for any mechanical movement. DMs are easy to control and very powerful, however, they usually have a smaller upstroke compared with AL and require a folded beam, which leads to a bulky optical setup in general. ALs do not need a folded beam because they are translucent elements, so the setup is more compact. There are various realisations of ALs. The most popular concepts include tunable acoustic gradient (TAG) lenses [11], liquid crystal lenses [12], lenses actuated by electrowetting [13], and deformable lenses with piezo actuators [10; 14; 15]. For axial scanning, the focal spot has to be shifted in the axial direction through the sample. To achieve such a shift, the AL induces a difference of the optical path length (\(OPL\)) when a beam is passing through the lens. Here, the \(OPL\) is defined according to Equation (1), where \(n\) is the refractive index of the lens material and \(s\) is the length of the path through the lens:  
\[OPL=n\cdot s \tag{1}\]  
TAG lenses achieve this by using sound energy to change the refractive index of the medium inside the lens [11], while the length \(s\) is constant. The alternative to a change of the refractive index is to adjust the local thickness of the lens by the deformation of the AL membrane with piezo actuators [14]. Such lenses enable high-speed axial scanning without the need for mechanical movement of the stage or microscope objective. However, environmental influences have a huge impact on the behavior of the AL. Therefore, it is necessary to monitor the behavior of the lens while scanning and to always be aware of the current position of the focal spot. The control of AL with higher degrees of freedom, such as the lens with spherical aberration correction capabilities introduced in [14], becomes more challenging as the axial position of the focal plane varies based on unknown or non-linear dependencies. If such an AL is inserted into an optical setup closed-loop control supported by wave, front measurements can be used for control. There, the voltage is iteratively refined until the desired behaviour is reached. However, this is time-consuming, and the sample is exposed to the laser for a significant amount of time, hence, photobleaching might pose a problem. To overcome these limitations we introduce a computational approach to estimate the current position of the focal plane while scanning and without iterations in the scanning process. The strategy is to monitor the behaviour of the scanning AL with a camera and assign the axial position to the recorded measurement point. In several use cases, techniques of deep learning were able to solve non-linear problems better than a classical closed loop control [16]. Neural networks as a method of deep learning are able to consider a huge amounts of information with unknown importance [17]. Furthermore, a neural network avoids time-consuming iterations once it is trained, and photobleaching is expected to be strongly reduced.