Deep learning enabled laser speckle wavemeter with a high dynamic range

The speckle pattern produced when a laser is scattered by a disordered medium has recently been shown to give a surprisingly accurate or broadband measurement of wavelength. Here we show that deep learning is an ideal approach to analyse wavelength variations using a speckle wavemeter due to its ability to identify trends and overcome low signal to noise ratio in complex datasets. This combination enables wavelength measurement at high resolution and over a broad operating range in a single step, which has not been possible with previous approaches. We demonstrate attometre-scale wavelength resolution over an operating range from 488 nm to 976 nm. This dynamic range is six orders of magnitude beyond the state of the art.


Introduction
A key property of monochromatic optical waves is their wavelength. An accurate measurement of wavelength can enable many studies in flourescence spectroscopy, atomic physics, and high 1 arXiv:1910.10702v1 [physics.optics] 22 Oct 2019 precision metrology (1,2). A standard wavemeter has a limitation of a one dimensional dispersion. Using a dispersive element such as a diffraction grating can provide high bandwidth but resolution scales linearly with system size, whereas stabilised Fabry-Perot cavities can obtain high resolution over a narrow operating range (3). Recently, it has been recognised that speckle, which is the grainy interference pattern produced when light propagates through a disordered medium, can overcome these limitations by multiplexing spatial-to-spectral mapping in a compact system. Tracking changes in this speckle pattern allows wavelength measurement with high resolution and broad operating range (4). For wavelength measurement, speckle may be generated by passing light through either a multi-mode fibre (5)(6)(7)(8)(9) or into an integrating sphere (10,11).
Capturing the speckle is insufficient: the critical step relies on the interpretation and understanding of changes in speckle pattern as a function of wavelength. Most of the previous applications use a method of calculating the transmission matrix of the given disordered medium (12), and this gives the capability to measure wavelength over a range restricted solely by the sensitivity range of the camera used to image the speckle. However, the resolution of this method is limited by a high degree of correlation between the speckle patterns produced at closely-separated wavelengths (13), typically on the picometre-scale. Multivariate analysis, in particular principal component analysis (PCA), adds a new dimension to this methodology and has allowed attometre-resolved wavelength measurements (9). However, PCA allows for only a limited range of operation that has been demonstrated to be, at most, 5 orders of magnitude higher than the resolution (10). Whilst these are impressive, to truly convert speckle into a very precise measurement, a powerful single-step algorithm would be desirable. The speckle patterns generated after transmitting light through a disordered medium are unique for each wavelength, with the presence of inherent noise due to environmental or instrumental variations. As a consequence, speckle is likely to be an ideal candidate for the training of a deep learning based classification method (14).
Deep learning is a powerful technique which has provided major advances in many areas of sciences, from evolutionary biology to quantum physics (15,16). Particularly, deep learning based artificial neural networks (ANNs) automatically learn to identify and extract the relevant features present in an input dataset (17). Moreover, the methodology for the application of ANNs makes them universal functional approximators (18) which are widely applied across physical sciences (19)(20)(21). Convolutional neural networks (CNNs) have already found application in speckle analysis for imaging applications (22,23). Of particular relevance here, they have also been implemented to discriminate between different speckle-creating scatterers (24).
Additionally, harnessing the spectral characteristics of speckle, CNNs have found an application to achieve real-time recovery of hyperspectral information with a wavelength resolution of 5 nm (25).
In this study, we present a method based on deep learning and t-distributed stochastic neighbor embedding (t-SNE) (26) to classify and segment the speckle images corresponding to a given laser wavelength. An interesting aspect presented in this study is the automatic rejection of instrumental or environmental noise by the CNN. This enables a classification of speckle patterns with a wavelength resolution of 2 am, 9 orders of magnitude improvement compared to (25). This, coupled with the capability of the pre-trained CNN to segment the speckle images covering the entire visible spectrum, leads to a dynamic range covering 11 orders of magnitude with this single step algorithm. Going beyond the capability to identify the speckle-creating scatterer (24), we additionally show that the trained CNN can recognize the wavelength variations of speckle regardless of which scattering medium is used. Figure 1: Speckle wavemeter assembly and CNN geometry. (a) The experimental assembly for a speckle wavemeter. The laser wavelength is set using an acousto-optic modulator (AOM) and injected into the disordered medium via a single mode fibre (SMF). The output speckle pattern is captured by the camera. (b) The convolutional neural network (CNN) used to classify the speckle images with respect to the incident laser wavelengths. The CNN consists of an input layer, multiple down-sampling blocks (DSB i ) and three fully connected layers (FC i ). Here λ i denotes the output wavelength class. The white scale bar on the representative speckle pattern represents 224 µm, while the intensity is normalized as shown in the adjacent color bar.

Principle of technique
We record on a camera the speckle patterns produced by scattering laser light from a disordered medium ( Fig. 1 (a)). Unless stated otherwise, we use a tunable diode laser which is wavelength-locked to a rubidium reference (∼ 780 nm) as our source of laser light, an acoustooptic modulator to apply controlled wavelength variations, and an integrating sphere to scatter light. Full details can be found in Methods section. To extract the wavelength dependence of the accumulated speckle images we implemented a supervised deep learning based convolutional neural network (depicted in Fig. 1 (b)). Details are provided in Methods section.

CNN optimization and noise rejection capabilities
For the optimization and calibration of the CNN, we varied the wavelength in 2 fm steps over a range of 60 fm. The complete dataset consisted of 10,000 images corresponding to each wavelength, which were randomly divided into training, validation and test datasets by the fraction of 70%, 15% and 15% respectively. After the training process, a total of 45,210 images were considered for testing the performance of the CNN. The classification by the CNN led to a very accurate measurement with 100% classification accuracy and a probabilistic classification error of 2.2×10 −6 . To emphasize this fact, we calculated the confusion matrix from the softmax output of the CNN over log 10 scale, which is presented in Fig. 2.
To calibrate the CNN, training is performed using every image in the training set. During the training, a global error is computed by parsing a batch of images sampled randomly from each class of the training set. During the backward pass, this calculated error is backpropagated such that the network can identify the features representing each individual class. In this study, this process is implemented to optimize a CNN architecture over the femtometre-resolved speckle patterns for gaining maximum classification accuracy over the validation dataset.
It has been shown in a previous study that the CNN, once trained on a given dataset, learns to overcome a low signal to noise environment (27). In our study we find analogous results.
Through the training process, the CNN learns to reject variations in the speckle patterns which do not correspond to the control parameter, i.e., wavelength. This is demonstrated in Fig. 3, where we analysed the speckle images by implementing PCA on both the input raw images and the processed output of the CNN. For a time-series of raw input speckle images (accumulated for 1 second) at a fixed wavelength, the first principal component (PC1) of the input images show several periodic noise components. However, when the output of the convolution network is analysed using PCA, PC1 does not reflect any of the temporal noise components that were present in the input dataset. This shows that the CNN, once trained to classify the speckle images with respect to wavelengths, filters the input speckle images and returns the output as a 1D vector representing a single wavelength without any environmental or instrumental noise.
Given the widely-known capability of ANNs to operate as universal functional approximators (18), the results in Fig. 3 (d) and Fig. 3 (e) also orient us towards a conclusion that once the CNN is trained to classify the speckle images for a single wavelength, it processes the input images to down-sample them into one dimensional vector such that any noisy components are rejected. This suggests that we can further train the CNN to recognise the incident laser wavelength with a precision below the instrumental circuitary noise.

Attometre resolution
In order to observe the limit of detection of the trained deep learning model, we accumulated a second dataset where the laser wavelength was tuned over separations on the attometre scale. More specifically, the speckle images were captured by detuning the acousto-optic modulator across five distinct wavelengths with an increment of 2 am. As the dataset is changed, the classification abilities of the CNN needs to be re-tuned, hence by the virtue of transfer learning, we retrained the CNN by changing the number of neurons in the output layer (F C 3 ). A total of 7000 images per wavelength class were considered for training/validation and 3000 images per class were considered for the testing process. The retrained CNN gave a 100% classification accuracy with a probabilistic classification error of 3.8 × 10 −5 . To emphasize the accuracy of measurement, we show the log 10 of the confusion matrix in Fig. 4 (a). This matrix was calculated from the activations of softmax layer at the output of the trained CNN. These results show that the re-training of a CNN can result in a wavelength resolution as low as 2 am.
To eliminate the process of retraining the CNN, the images were also processed using the pre-trained CNN. The output 1D vectors at F C 1 (see methods) were further analysed using t-SNE to visualize the segmentation capabilities. Figure 4 (b) denotes the output of F C 1 layer of the CNN downsampled to a 2 dimensional latent vector space. Each cluster represents the speckle images corresponding to a specific wavelength. Evidently, using this method we do not need to train the CNN further using 7000 images per class but we can use only a single image for the further classification, and still achieve attometre-scale resolution.
The resolving power of a wavemeter is R = λ 0 δλ , where λ 0 is the absolute wavelength and δλ is the minimum detected deviation from it. The resolving power of the deep learning enabled speckle wavemeter is R > 10 11 for a central wavelength at rubidium reference with a least deviation of 2 attometre.

Broadband operation range
We tested the broadband segmentation capabilities of the CNN by accumulating the speckle patterns over two wavelength ranges: from 770 nm to 790 nm in 5 nm increments and separately at 488 nm, 532 nm, 785 nm and 976 nm (see Methods for details).
When the trained CNN was implemented over the two datasets, and the output of F C 1 was analysed using t-SNE, the speckle images corresponding to individual wavelength were clustered independently as depicted in Fig. 5 (a) and Fig. 5 (b). This result shows that the CNN, once trained, can be harnessed for the classification of speckle images at a broadband range between 488 nm to 976 nm regardless of the variation in the incident laser wavelength.
As before, without retraining the CNN, t-SNE evaluation of the output of F C 1 shows a clear clustering of the classes, meaning that a full retraining is not necessary, but wavelength detection can be accomplished simply by using one known wavelength per cluster. The fractional bandwidth of the wavemeter is B = (λ max − λ min ) 1 2 (λ max + λ min ), where λ max is the maximum detected wavelength and λ min is the minimum detected wavelength in the broadband operation range, giving B = 0.66 for the speckle wavemeter presented here. Defining the dynamic range as the product B × R, these results showcase the high dynamic range capability of the CNN in classifying the speckle patterns: identifying wavelength differences with a resolution of a few attometres over a range of 100s of nanometres gives a high dynamic range of 3.25 × 10 11 .

Generalization capabilities of the CNN
The speckle pattern represents the spatial correlation function of a given disordered medium and the incident light wavelength. This means that if the medium is changed the speckle pattern would also change, whilst maintaining the wavelength dependent deviations. Therefore, with respect to the generalization capability, a deep learning based model trained to decorrelate the speckle patterns with respect to wavelength should in principle be able to segment the speckle images generated from any random disordered medium. To consider this theory of generalized segmentation properties, we accumulated a dataset using a ground glass diffuser (Thorlabs ED1-S20) in place of the integrating sphere. As can be observed from Fig. 6 (a) and Fig. 6 (b), the speckle patterns generated from the integrating sphere and the ground glass show completely different characteristic features.
We accumulated two sub-datasets, one where the speckle images were accumulated by varying the incident wavelength with an increment of 2 fm and the other with an increment of 20 am.
The segmentation capability of the CNN was tested by processing the speckle images generated from each class. The output from F C 1 was analysed using t-SNE and the results are presented in Fig. 6. As shown in Fig. 6 (c) and (d), the CNN segments and clusters each of the speckle images into their individual class.
The results clearly show that the CNN processed the images, which represented completely different spatial variations, and clustered them with respect to the incident laser wavelength.

Discussion and Conclusions
The combination of speckle with CNNs achieves a remarkable classification accuracy since speckle patterns represent an ideal candidate for the training of the CNN. As shown in Fig. 2, the CNN achieves a 100 % classification accuracy with a probabilistic classification error of 2.2 × 10 −6 . We have also demonstrated that the CNN, once trained to classify the speckle patterns, automatically learns to reject the environmental or instrumental fluctuations. If the disordered medium and the laser wavelength are kept constant then, ideally, the resulting speckle pattern should not change. However, the environmental fluctuations or fluctuations due to instrumental circuitry cause the speckle patterns to change with time.
As can be inferred from Fig. 3, the structure of a CNN model and backpropagation training, drives it to progressively learn the filtering of the input images. As explained before, the training is implemented such that the output only contains the features relevant to the individual class of the images in the training dataset. In the case of a speckle wavemeter, conceptually, the speckle images should be down-sampled such that the output only contains the features with respect to the wavelength. In this study, we have demonstrated that the CNNs can accurately classify speckle patterns measured with a wavelength separation of 2 am (Fig. 4)  In conclusion, this study has implemented a deep learning based method to classify the speckle patterns with respect to the incident light source wavelength. The combination of laser speckle and deep learning provides an accurate method to distinguish between laser wavelengths separated by as little as 2 am and as much as 488 nm, showing a dynamic range of 3.25×10 11 in a single-step algorithm. This combination can also be applied to a completely distinct scattering medium, and re-calibrating the CNN using the method of transfer learning provides an efficient training procedure for a highly accurate wavemeter.
Additionally, this study shows that a trained deep learning model can be implemented to reject inherent instrumental or environmental noise. The results presented here will be beneficial in not only automated laser stabilization but may also be useful for noise reduction in multiple telecommunication applications. In the future, we will investigate extending this work to the development of highly robust and compact spectrometers with a capability to measure multiple wavelengths.

Data Acquisition
The speckle images corresponding to the incident laser wavelength were generated by using a 1.5 inch diameter, spectralon integrating sphere based assembly. The laser light from an external cavity diode laser (Topica DL-100 / LD-0785-P220) was stabilized to the 87 Rb D2 line (F = 2 → F = 2 × 3 crossover) using saturated absorption spectroscopy and top-offringe locking. The light from the laser was passed through an acousto-optic modulator (AOM) (Crystal Technologies 3110-120) in a cat-eye double pass configuration. To remove any variations in the spatial beam profile, the light was coupled into an angle cleaved single-mode fibre (SMF) (Thorlabs P5-780M-FC-10). The SMF delivered 900 µW into the integrating sphere.
The highly Lambertian diffusive coating and multiple reflections create large optical path differences allowing a high resolution for the system. The light then propagates for 20 cm before impinging the CMOS camera (Mikrotron EoSens 4CXP) resulting in speckle patterns as shown in Fig. 1 (a). To test the wavemeter over a broader range of the optical spectrum, we use ad- During the data accumulation, we recorded a continuous train of 10,000 128 × 128 pixel speckle images for each wavelength at a frame rate of 1 kHz with an exposure of 998 µs.

Deep learning model architecture, training and calibration
To extract the wavelength dependence of the accumulated speckle images we implemented a supervised deep leaning based convolutional neural network (CNN) (depicted in Fig. 1(b)).
The implemented CNN architecture consists of 4 down-sampling blocks (DSB). Each block consists of 3 convolution layers with 30 filters. Each convolution layer is followed by a batch normalization layer and a rectifier linear unit (ReLU) activation function layer. To systematically reduce the dimensionality of the input image, each DSB is connected with a max pooling layer with filter size of 2 px × 2 px. The filter sizes of convolution layers vary as 5 px × 5 px, 4 px × 4 px and 3 px × 3px respectively with a stride and padding of 1 px × 1 px. The DSBs are followed by two fully connected (FC) layers with leaky ReLU (28) as the activation function.
Each FC layer with 128 neurons was followed by a dropout layer (29). These layers were then fully connected to the output layer having n neurons with softmax activation function, here n denotes the number of wavelength classes. For attaining maximum classification accuracy over the validation dataset, the above mentioned architecture was chosen after optimizing: the number of DSBs on the range 1 to 10; the number of convolution layers between 1 and 5 for each block; the filter sizes from 1 px × 1 px to 8 px × 8 px; and the number of neurons from 8 to 512 by doubling the neurons at each step.
The CNN geometry was optimized by considering the first dataset comprising the speckle images corresponding to 30 different wavelengths at a deviation of 2 fm. This dataset was randomly sampled into 70% training, 15% validation and 15% testing images corresponding to each wavelength. The training was implemented in Matlab 2018a over Nvidia Quadro P5000 GPU. To remove any intensity dependent fluctuations, all the speckle images were zero-center normalized. The CNN was trained to minimize the cross entropy cost function for 10 epochs in the mini batches of 128 images using an ADAM optimizer (30), where Σ x represents training over all the input images x, k is the total number of training data points, y is the target output and a is the network output. Here y and a are the one hot vectors representing the category of the input image. Initial learning rate was set at 1 × 10 −6 and L2regularization at During the training, the CNN learns to generalize the wavelength-dependent variations of the speckle patterns and thus classify them. The complete CNN architecture can be considered as composed of two ANNs, namely a convolution network (input layer to FC1) and a classifier network (FC2 and FC3). The primary function of the convolution network is to down-sample the 2D input image into a 1D descriptor vector by filtering out the irrelevant / noisy features, whereas the classifier network is trained to classify these 1D descriptor vectors. Thus for a given time instant, where the speckle field is constant with respect to the environmental fluctuations, the convolution network learns to produce a 1D descriptor vector (128 px) corresponding to a particular wavelength for the input 2D image (128 × 128 px). Hence, after training, the vector output of the convolution network can be directly considered for further analysis.

t-distributed stochastic neighbor embedding analysis
To visualize the convolution network's segmentation capabilities over the different datasets, we implemented t-distributed stochastic neighbor embedding (t-SNE) over the generated 1D vectors. t-SNE is a well known non-linear method of machine learning which works on the principle of embedding a low dimensional space such that the neighborhood probabilistic distribution of the higher dimensional data is preserved in the low dimensional vector space. This is achieved by minimizing the symmetric form of Kullback -Leibler divergence (26). In this study, t-SNE analysis with a perplexity of 30, was implemented using MATLAB 2018b.