{'fraction_non_alphanumeric': 0.03416006430129751, 'fraction_numerical': 0.010736020208979217, 'mean_word_length': 4.720525451559935, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 0, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Classical-to-Quantum Transfer Learning for Spoken Command Recognition Based on Quantum Neural Networks

This work investigates an extension of transfer learning applied in machine learning algorithms to the emerging hybrid end-to-end quantum neural network (QNN) for spoken command recognition (SCR). Our QNN-based SCR system is composed of classical and quantum components: (1) the classical part mainly relies on a 1D convolutional neural network (CNN) to extract speech features; (2) the quantum part is built upon the variational quantum circuit with a few learnable parameters. Since it is inefficient to train the hybrid end-to-end QNN from scratch on a noisy intermediate-scale quantum (NISQ) device, we put forth a hybrid transfer learning algorithm that allows a pre-trained classical network to be transferred to the classical part of the hybrid QNN model. The pre-trained classical network is further modified and augmented through jointly fine-tuning with a variational quantum circuit (VQC). The hybrid transfer learning methodology is particularly attractive for the task of QNN-based SCR because low-dimensional classical features are expected to be encoded into quantum states. We assess the hybrid transfer learning algorithm applied to the hybrid classical-quantum QNN for SCR on the Google speech command dataset, and our classical simulation results suggest that the hybrid transfer learning can boost our baseline performance on the SCR task.


INTRODUCTION
The state-of-the-art baseline system of spoken command recognition (SCR) [1,2,3] is built upon the advancement of deep learning (DL) technology [4]. The DL technologies highly rely on two important aspects: (1) powerful computational resources arisen from the graphical processing unit (GPU); (2) the availability of access to a large amount of labelled or unlabelled training data [5,6]. Despite the rapid empirical progress of the SCR systems, deep learning models are becoming computational expensive and, now that Moore's law is faltering [7], it is necessary to contemplate a future technology to further deal with a huge amount of speech data. However, new exciting possibilities are opening up due to the imminent advent of quantum computing devices that directly exploit the laws of quantum mechanics to evade the technological limits of classical computation [8].
The exploitation of quantum computing machines to carry out quantum machine learning (QML) [9] is still in its initial exploratory stage. In particular, a quantum neural network (QNN) [10], which is capable of carrying out a universal quantum computation, attracts much attention in the domain of QML because it can be seen as a quantum analog of the classical deep neural network (DNN). Hence, the QNN model allows the algorithm of back-propagation to train the model parameters of the QNN. However, in the age of noisy intermediate-scale quantum (NISQ) devices [11], it is necessary to simulate quantum experiments with noisy quantum circuits that may degrade the baseline performance. A compromised QNN, namely variational quantum circuit (VQC), has been proposed to overcome the influence of quantum noise in the QNN. The advantages of the VQC in the QNN arise from many aspects: (1) a VQC is a quantum circuit with adjustable parameters that are optimized according to a predefined metric; (2) VQC is flexibly placed on a NISQ machine and can be resilient to the quantum noisy effects on quantum circuits.
Prominent examples in the hybrid QNN for machine learning tasks include quantum reinforcement learning [12], quantum image processing [13], and quantum circuit learning (QCL) [14], where the VQC model plays an important role as a quantum component. Particularly as for the application of QNNs for SCR, our pioneering work [15] investigates the use of quantum convolutional neural networks to extract quantum speech features as the input to state-ofthe-art classical deep neural networks. However, the work [15] does not employ the QNN as an end-to-end SCR model, and it is still unknown about the performance of QNNs for SCR. Hence, in this work, we attempt to build a hybrid classical-quantum QNN model for SCR. In particular, we make use of a hybrid transfer learning approach to speed up the end-to-end training framework based on the QNN model.
Classical transfer learning [16,17] is a typical example of machine learning that has been originally inspired by biological intelligence, and it originates from the knowledge acquired in a specific context which can be transferred to a different area. For example, when we learn a foreign language, we always make use of our previous linguistic knowledge to speed up the learning rate [18]. This general idea has been successfully applied to artificial intelligence and machine learning domains. It has been shown that in many situations, instead of training a full network from scratch, it should be more efficient to start from a pre-trained network so that only some model components need further fine-tuning for a particular task of interest. The transfer learning methodology is very related to the training of a hybrid classical-quantum QNN, where the classical component can be pre-trained in another generic model and directly transferred to the hybrid QNN.
This work aims to investigate a hybrid classical-to-quantum transfer learning paradigm in the context of a QNN-based SCR system. Our baseline system, namely CNN-DNN, consists of two core components: (1) convolutional neural network (CNN) for speech feature extraction; (2) DNN for recognizing commands. In this work, we first build a hybrid classical-quantum model, namely CNN-QNN, where the CNN is still kept for feature extraction and the DNN is replaced by the QNN model. In doing so, a classical CNN-DNN becomes a hybrid classical-quantum CNN-QNN. Although the hybrid model follows an end-to-end learning pipeline, the frequent data conversion between classical and quantum states greatly slows down the computing efficiency in the training stage. Moreover, the current NISQ device admits only a small number of qubits for the QNN so that the representation power of the CNN-QNN may become quite limited. Thus, a new training strategy needs to be proposed. Here, we put forth a novel hybrid transfer learning strategy. In more detail, given a well-trained classical CNN-DNN, the CNN model is taken to initialize the CNN component of the CNN-QNN and several additional training steps are conducted to fine-tune the parameters of the QNN.
The rest of the paper is organized as follows: Section 2 introduces some notations. Section 3 introduces the architecture of the VQC-based QNN. Section 4 presents the framework of our SCR system. Section 5 shows the hybrid transfer learning algorithm. Our simulation results will be reported in Section 6, and the paper is concluded in Section 7.

NOTATIONS FOR QUANTUM COMPUTING
|v d is a quantum state associated with a 2 d -dimensional vector in a Hilbert space, where for a scalar vi, the quantum state |vi can be written as Eq. (1).  1. The framework of quantum encoding bridges the relationship between the classical data input x and its quantum state |x . In other words, quantum encoding is associated with the generation of quantum embedding from the classical input vector x = [x1, x2, x3, x4] T . The quantum state |x can be written as Eq. (2).

VARIATIONAL QUANTUM CIRCUIT-BASED QUANTUM NEURAL NETWORK
Then, the circuits of quantum encoding in Figure 1 produce the following quantum state as Eq. (3).
2. The model of the VQC in the dashed square consists of CNOT gates and adjustable rotation gates RX , RY , RZ . The CNOT gates mutually impose quantum entanglement between any two quantum wires, so that the qubits from all the wires can be entangled. The rotation angles αi, βi, and γi are adjustable and can be taken as the trainable parameters for RX , RY , and RZ , respectively.
3. The outputs of the quantum states should be projected by measuring the expectation values of 4 observablesẑ = [ẑ1,ẑ2,ẑ3,ẑ4] for a classical vector z as Eq. (4).
Moreover, the rotation gates RX , RY , and RZ , which are associated with the unitary matrices in Figure 2, stand for a linear mapping between quantum inputs and quantum outputs. One key advantage of the QNN is that fewer model parameters are involved in the QNN model. For example, Figure 1 shows 4 quantum wires and 6 VQC layers, which result in 72 trainable model parameters in the QNN. Besides, the QNN model can be trained in an end-to-end pipeline based on the back-propagation algorithm with different stochastic gradient descent (SGD) optimizers such as Adam [19], RMSprop [20], and Adadelta [21]. This is because the update of the QNN parameters follows a first-order optimization technique to minimize a loss function over the dataset, which is represented as Eq. (5).
where Θ = [Θ1, Θ2, ..., Θ d ] T are the parameters to be learnt, L is the loss over the data, and η is the learning rate. Given a small , the partial derivative term can be approximated by using the finite difference method as Eq. (6).

HYBRID CLASSICAL-QUANTUM QNN FOR SCR
Next, we illustrate the architecture of the hybrid classical-quantum QNN model for SCR in Figure 3. The CNN framework consists of four 1D convolutional layers (Conv1D) followed by batch normalization (BN) and the ReLU activation. A max-pooling layer with a kernel of 4 is also used after each Conv1D. The output of the CNN framework is a set of high-dimensional CNN features, which should be compressed to low-dimensional features (Dense) connected to the quantum encoding framework in a QNN. The encoded quantum states go through the QNN model and the measured outputs correspond to the classification labels for a certain task. The output of the QNN is connected to a classification layer by a non-trainable matrix. This hybrid classical-quantum QNN is denoted as CNN-QNN.

Low-dimensional features
Classification CNN features Speech signals Fig. 3. A classical-quantum hybrid QNN for SCR. CNN is utilized as feature extraction and QNN is applied for classification. Figure 4, where the QNN is replaced by a classical DNN. The feature reduction component is removed, but more model parameters are included in the DNN model.

CLASSICAL-TO-QUANTUM TRANSFER LEARNING
As discussed in the introduction, hybrid classical-to-quantum transfer learning is significantly appealing in the current technological era of NISQ devices. Although there are so many technical limitations in the usage of quantum computing nowadays, e.g., a small number of available qubits and noisy quantum circuits, the NISQ computers are approaching the quantum supremacy milestone [22,23]. At the same time, we could make use of the very successful and well-tested tools of classical deep learning, especially for speech and language processing tasks in which some specific datasets are not large enough to attain well-trained neural networks. However, prior knowledge of some networks that are pre-trained on generic datasets can be shared with a new model for a specific task. In classical machine learning, transfer learning has been widely used in certain applications. For example, the generative pre-trained transformer (GPT) [24] and bidirectional encoder representations from transformers (BERT) [25] are always adapted to particular language processing tasks by simply appending a few neural networks on top of the pre-trained language models. Similarly, a hybrid classical-to-quantum transfer learning algorithm comprises of applying exactly those classical pre-trained models as feature extractors and then post-processing these features on a quantum computer. As for our transfer learning algorithm applied to SCR, a pre-trained generic CNN-DNN model is obtained beforehand based on a classical generic dataset as shown in Figure 5. The CNN model of the pre-trained CNN-DNN, namely CNN', is transferred to the CNN-QNN, which generates CNN'-QNN. During the training stage of the CNN'-QNN, the CNN' model is fixed, and only the parameters of the QNN need further fine-tuning on the classical specific dataset. Since the transferred CNN is not involved in the training process, a small number of specific training data is enough to optimize the model parameters of the QNN. Besides, the hybrid classical-to-quantum transfer learning significantly speeds up the training efficiency because the overhead of the frequent communication between classical and quantum devices can be avoided.

EXPERIMENTS
In this section, we assess our hybrid transfer learning algorithm for CNN-QNN in the following aspects: 1. Performance gain can be obtained by applying the hybrid transfer learning technique.
2. The hybrid transfer learning can work with both noiseless and noisy quantum circuits.

Data profile
Our SCR task was conducted on the Google speech command dataset [26]. The dataset is composed of 11, 165 development and 6, 500 test utterances, which come from 35 spoken commands, e.g., ['left', 'go', 'yes', 'down', 'up', 'on', 'right', ...]. The development data are randomly split into two parts: 90% is used for model training and 10% is used for model validation. All the audio files are about 1 second long, downsampled from 16KHz to 8KHz. The batch size was set to 256 in the training process, and the speech signals in a batch were configured as the same length by zero padding.

Experimental setup
Our baseline CNN-DNN system is based on the classical neural network architecture as shown in Figure 4, and our proposed CNN-QNN model is shown in Figure 3. The two models share the same CNN framework, which consists of 4 CNN blocks. Each CNN block is composed of a Conv1D followed by BN and ReLU, and a maxpooling is used to reduce the dimension of the speech features. The kernel size and stride are set as 80 and 16, for the first CNN block, and 3 and 1, respectively for the other CNN blocks. Moreover, the number of channels for each block follows the 1 − 32 − 64 − 64 configuration. Besides, the kernel size was configured as 4 for the max-pooling layer of each CNN block. The time-series signal is directly fed into the first CNN block, and the output of the CNN framework is related to 64-dimensional abstract features.
As for the classical CNN-DNN, the setup of the DNN is as follows: the hidden layers of the DNN were configured as 64 − 128 − 256 − 512, and the ReLU activation function was imposed upon each hidden layer except the top hidden layer. The output of the CNN-DNN was connected to 35 classes, which correspond to the spoken commands.
For the setup of the CNN-QNN, the number of qubits was set as 8 and the classical abstract features need to be further compressed to 8 dimensions. The 8 classical features were encoded into quantum embeddings that go through the VQC model. Since 8 channel wires were applied and 4 repetitive VQC models were used, this leads to 96 adjustable parameters in total.

Experimental results with noiseless quantum circuits
We first examine the performance of the CNN-QNN end-to-end model, where the noiseless quantum circuits are considered. In addition to the comparison with the CNN-DNN model, our method is also compared with prominent neural network models available in the literature, namely: DenseNet-121 benchmark [2], Attention-RNN [1,27], and QCNN [15]. QCNN denotes the use of quantum convolutional features for the task. We extend the 10-class training setup in [15] to 35 classes. Moreover, all deployed models are trained with the same SCR dataset from scratch, without any data augmentation or pre-training techniques to make a fair architecturewise study.

Experimental results with noisy quantum circuits
Next, we discuss the hybrid transfer learning algorithm on the NISQ device, where noisy quantum circuits are considered. More specifically, we follow an established noisy circuit experiment with the NISQ device suggested by [12]. One major advantage of the setups is to observe the robustness and preserve the quantum advantages of a deployed QNN with a physical setting being close to quantum processing unit (QPU) experiments.
As for the detailed setup, we first use an IBM Q 20-qubit machine to collect channel noise in the real scenario for a deployed QNN and then upload the machine noise into our Pennylane-Qiskit [28] simulator. As shown in Table 3, the hybrid transfer learning algorithm still achieves good results with much fewer parameters. Although with the noisy quantum circuits, both CNN-QNN 2 and CNN-QNN 3 cannot outperform the classical CNN-DNN, their results are very close. Furthermore, the empirical performance of CNN-QNN 2 and CNN-QNN 3 would become much better when fault-tolerant quantum computers could become available.  Table 3. The experimental results on the test dataset. The simulations were conducted with noisy quantum circuits.

CONCLUSIONS
This work focuses on a hybrid classical-to-quantum transfer learning algorithm for QNNs applied to SCR. We first set up the VQC-based QNN, and then design a CNN-QNN-based SCR system. We employ hybrid transfer learning to transfer a pre-trained CNN framework to our CNN-QNN system so that better performance could be obtained. Our experiments on the Google speech command dataset show that the hybrid classical-to-quantum transfer learning is of significance in enhancing classification accuracy and lowering cross-entropy loss value for the CNN-QNN model.