{'fraction_non_alphanumeric': 0.033360723089564503, 'fraction_numerical': 0.00901122980005478, 'mean_word_length': 4.763378058405682, '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': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Reconfigurable Intelligent Surface Based Hybrid Precoding for THz Communications

Benefiting from the growth of the bandwidth, Terahertz (THz) communication can support the new application with explosive requirements of the ultra-high-speed rates for future 6G wireless systems. In order to compensate for the path loss of high frequency, massive multiple-input multiple-output (MIMO) can be utilized for high array gains by beamforming. However, since a large number of analog phase shifters should be used to realize the analog beamforming, the existing THz communication with massive MIMO has very high energy consumption. To solve this problem, a reconfigurable intelligent surface (RIS)-based hybrid precoding architecture for THz communication is developed in this paper, where the energy-hungry phased array is replaced by the energy-efficient RIS to realize the analog beamforming of the hybrid precoding. Then, based on the proposed RIS-based architecture, a sum-rate maximization problem for hybrid precoding is investigated. Since the phase shifts implemented by RIS in practice are often discrete, this sum-rate maximization problem with a non-convex constraint is challenging. Next, the sum-rate maximization problem is reformulated as a parallel deep neural network (DNN)-based classification problem, which can be solved by the proposed low-complexity deep learning-based multiple discrete classification (DL-MDC) hybrid precoding scheme. Finally, we provide numerous simulation results to show that the proposed DL-MDC scheme works well both in the theoretical Saleh-Valenzuela channel model and practical 3GPP channel model. Compared with existing iterative search algorithms, the can proposed DL-MDC scheme reduces the runtime significantly with a negligible performance loss.


I. INTRODUCTION
6G is expected to achieve about a 100-fold increase in data rate than 5G [1]- [3]. Due to the tremendous growth of the bandwidth, Terahertz (THz) communication has been regarded as a promising technology for future 6G wireless systems to support the high data rate application. Compared with the typical bandwidth of several GHz in the millimeter-wave (mmWave) band  for 5G [4], the THz band (0.1-10 THz) is able to provide tens of GHz bandwidth [2]. One of the major obstacles for THz communication is the severe propagation attenuation at high frequencies [1]. Similar to mmWave communication, in order to alleviate the severe signal attenuation problem, THz communication can also use hybrid precoding based on massive multiple-input multiple-output (MIMO) to generate directional beams with high array gains [3].
However, the direct application of hybrid precoding in THz communication will result in the very high energy consumption mainly due to the following reason. It is well known that the phased array based hybrid precoding requires a large number of analog phase shifters to realize the analog beamforming in mmWave communication, and this number in THz communication will be significantly increased, since much more antennas should be used to compensate for the more severe attenuation of THz signals than mmWave signals. For instance, 128 or 256 antennas are usually considered in mmWave systems, while 1024 or 2048 antennas have been considered in THz systems [5].
Fortunately, the recently proposed reconfigurable intelligent surface (RIS) is regarded as a revolutionary technique to provide an energy-efficient alternative to the traditional energy-hungry phased array [6]. Specifically, RIS is an artificial metasurface consisting of a large number of low-cost and passive elements. Each element on RIS is able to reflect the incident signal while adjusting its phase shift individually [7]- [9]. The elements on RIS are nearly passive without the need of dedicated radio frequency (RF) chain, so they can realize phase shifts in an energyefficient way. By individually manipulating the phase shifts of elements on RIS in a preferred way, RIS is able to generate dynamic directional beams to different users in real time according to the changing wireless channels and mobile users. Note that RIS is also different from the existing lens antenna array, which can only provide fixed beams with fixed phase shifts [10].
Thus, RIS is a potential technique to address the high energy consumption problem for THz communication.

A. Prior works
The main applications of RIS in wireless communication systems can be divided into two categories: a reflective relay, and an antenna array.
First, RIS can be used as a reflective relay to reconstruct the channel link blocked by buildings or other objects, which enhances the wireless link robustness and optimizes the link outage probability [11], particularly for mmWave and THz communications. Moreover, RIS also has some other advantages, such as increasing the coverage area, enriching the channel with larger number of multi-paths, reducing the transmit power, etc. [12]. Some recent works have investigated the performance of the wireless system with RIS acting as a relay [11], [13], [14]. These works mainly concentrate on the optimal RIS beamforming design to enhance the performance of wireless communication. Specifically, the authors in [13] proposed an alternating optimization for a single RIS to maximize the signal-to-noise ratio (SNR) of a single user as well as multiple users, where the ideal continuous phase shifts of the RIS are considered. Furthermore, the optimal RIS beamforming design was investigated for multiple RISs, which is also based on the continuous phase shifts [15].
However, the continuous phase shifts on RIS are challenging to realize in practice due to the hardware constraint of RIS, e.g., the most recently reported RIS prototype at mmWave frequency 28 GHz can realize up to 2-bit discrete phase shifts [16]. Fortunately, it has been proved that the gap of the sum-rate performance between the discrete phase shift (even for the 1-bit phase shifter) and the continuous phase shifter is negligible, and it keeps constant when the number of RIS elements approaches infinity [17]. Thus, we are likely to use RIS with discrete phase shifts for practical wireless communications. The passive RIS beamforming optimization problem with discrete phase shifts is non-convex. The exhaustive search can be used to find out the optimal solution to this non-convex problem, but the complexity is very high. The main way of reducing the complexity is to utilize the iterative search algorithms. For example, the authors have proposed the iterative search method for the RIS beamforming optimization to reduce the transmit power in [17] and increase the sum-rate in [18], respectively. However, this kind of iterative search schemes still suffers from the high complexity when the RIS dimension is large.
The second application of RIS is an antenna array, particularly equipped at the base station (BS). Compared with the typical multi-antenna transceiver, the RIS-aided transceiver has much lower energy consumption and hardware cost [19]. There are only very limited initial works for this kind of application for RIS [20], [21]. Specifically, in [20], the digital baseband signals are directly mapped to the control signals on RIS to change the reflection coefficients of RIS elements, so the RF modulation of the reflected electromagnetic waves can be achieved. It has been shown that a low-cost multi-stream transmitter is able to be implemented by a single-antenna feeder and an RIS. Furthermore, the architecture with a single-antenna feeder was proposed in [21], where the RIS is an integrated part of the transmitter at the BS, and it is claimed that the antenna feeder can be directly connected with the RIS transmitting modulated signals instead of reflecting them. However, these works use RIS to modulate the RF signals by simultaneously (not individually) controlling all RIS elements via the same control signals, so it is not easy to realize analog beamforming with high array gains.

B. Our contributions
In this paper, we first propose the RIS-based hybrid precoding architecture for THz communication with low energy consumption. The key idea of this architecture is to replace the energyhungry phased array in the conventional hybrid precoding architecture by the energy-efficient RIS to realize the analog beamforming. Then, for the proposed RIS-based hybrid precoding architecture, we formulate a sum-rate maximization problem, which is proved to be a classification problem. We further propose a deep learning-based multiple discrete classification (DL-MDC) hybrid precoding scheme to solve this classification problem with reduced complexity.
The specific contributions can be summarized as follows.
• Unlike most of the existing works that employ RIS at the transmitter to modulate RF signals without array gains, we utilize the energy-efficient RIS to replace the phased array to realize analog beamforming in THz communication systems in the proposed RIS-based hybrid precoding architecture. By individually controlling a great number of energy-efficient and low-cost passive elements instead of expensive phase shifters, the RIS in the RIS-based hybrid precoding architecture is able to reflect signals in directional beams to different users.
• For the proposed RIS-based hybrid precoding architecture, considering discrete phase shifts due to the practical hardware implementation of RIS, a sum-rate maximization problem is formulated in RIS-based THz communication. This non-convex constraint makes the sumrate maximization problem non-convex, so the optimization of the tunable discrete phase shifts of RIS to realize the optimal analog beamforming is challenging. Instead of using iterative search methods with high complexity to achieve the solution to this non-convex problem, the mapping relationship is analyzed between the channel matrix and the analog beamforming matrix at first, based on which the non-convex sum-rate maximization problem is reformulated as multiple discrete classification problems.
• We propose a DL-MDC algorithm to solve the reformulated sum-rate maximization problem by leveraging the excellent performance of deep neural network (DNN) for handling the classification problems. Specifically, the 1-bit phase shifts of RIS are considered in the proposed RIS-based hybrid precoding architecture, which can be easily implemented via diodes with very low power and cost. Instead of using one DNN directly, we develop a parallel DNN system to decide every non-zero element in the analog beamforming matrix, where each DNN of the parallel DNN system is constructed with only one output. The output of DNN is the posterior probability of phase shift being 0. Then, a reasonable threshold is set for the output to obtain the classification outcome. It is worth pointing out that, since the channel direction information is more important to generate directional beams than the channel gain information for analog beamforming, we preprocess the data samples based on the physical property of the hybrid precoding to take full advantage of DNN.
• We provide the simulation results of the proposed DL-MDC hybrid precoding scheme both in the theoretical Saleh-Valenzuela channel model [22] and the practical 3GPP channel model [23]. It is shown that the proposed scheme is able to predict the classification results precisely. Meanwhile, the near-optimal sum-rate performance can be achieved with low complexity.

C. Organization and notation
Organization: The rest of the paper is organized as follows. Section II describes the proposed RIS-based hybrid precoding architecture for THz communication at first, and then the sum-rate maximization problem is formulated under the hardware constraint of the proposed architecture.
In Section III, a low-complexity DL-MDC hybrid precoding scheme for THz communication is proposed to address the non-convex sum-rate maximization problem. Simulation results are provided in Section IV. Finally, some conclusions are drawn in Section V.
Notation: Lower-case and upper-case boldface letters a and A denote a vector and a matrix, respectively; A H , A T , and A −1 denote the conjugate transpose, transpose, and inversion of the matrix A respectively; A F denotes the Frobenius norm of the matrix A; Diag (A) denotes a column vector composed of the diagonal elements of A; diag (a) denotes the diagonal matrix whose diagonal elements consist of the elements in the vector a; a 2 denotes the l 2 -norm of the vector a; |a| denotes the amplitude of the scalar a; We use CN (m, R) to denote the complex Gaussian distribution with mean m and covariance R, and U(a, b) to denote the uniform distribution in the range (a, b); A denotes a set and card(A) denotes the number of elements in the set A; Finally, I K is the K × K identity matrix, and ⊗ denotes the kronecker product.

II. PROPOSED RIS-BASED HYBRID PRECODING ARCHITECTURE
In this section, we first introduce the system model of the proposed RIS-based hybrid precoding architecture for THz communication, where the analog beamforming of hybrid precoding will be realized by energy-efficient RIS instead of the energy-hungry phased array. Then, based on the proposed architecture, we formulate the optimization problem of hybrid precoding to maximize the sum-rate of all users with a non-convex constraint due to the discrete phase shifts in practical hardware implementation of RIS.

A. System model
In this paper, we consider a typical single-cell downlink THz massive MIMO system, where the BS employs M RF chains to serve K single-antenna users. M = K is assumed to fully exploit the multiplexing gain [24].
In the conventional phased array based hybrid precoding architecture illustrated in Fig. 1 (a), the RF chains are connected to the phased array for analog beamforming, and the number of required phase shifters is proportional to the number of RF chains as well as the number of antennas for the widely considered fully-connected scheme [25].
By virtue of the low-rank characteristics of mmWave/THz channels [26], the phased array based hybrid precoding is able to achieve the near-optimal performance. However, in mmWave systems, the number of antennas at BS is usually 128 or 256, while in THz systems this number is much larger, e.g., 1024 or 2048 in [5]. Thus, due to numerous energy-hungry phase shifters in THz systems, the conventional phased array based hybrid precoding architecture will result in very high energy consumption.
As shown in Fig. 1 (b), the proposed RIS-based hybrid precoding architecture for THz communication utilizes the energy-efficient RIS rather than the energy-hungry phased array for analog beamforming, where the RF signals are reflected by the RIS. Particularly, RIS is an artificial metasurface consisting of a large number of low-cost passive elements. These elements have the ability to generate dynamic directional beams with high array gains by individually manipulating their phase shifts [27]. Thanks to the passive RIS elements, compared to the conventional phased array based hybrid precoding architecture, the proposed RIS-based hybrid precoding architecture is capable to realize the analog beamforming in a more energy-efficient way.
Specifically, the RIS employs N passive elements, and each RF chain is only associated with a sub-surface consisting of a non-overlappping part of the passive elements in the proposed RISbased hybrid precoding architecture, as shown in Fig. 1 (b). Then, we assume that there are M sub-surfaces, and the signal from each RF chain is reflected by a unique sub-surface consisting of N s = N/M passive elements (N/M is assumed to be an integer for simplicity). Note that by carefully designing the size of the sub-surfaces and the distance between the RF chains and the RIS, the interference among different sub-surfaces can be ignored [28], which means that each RF chain's signal can be only reflected by a sub-surface with N s passive elements.
The signal y k received at the kth user is expressed as where s ∈ C K×1 is the transmitted signal vector satisfying E ss H = I K for all K users, and ing matrix, and g m ∈ C Ns×1 is the beamforming channel vector between the mth antenna feeder and the mth sub-surface; The analog beamforming matrix Φ m C Ns×Ns is a diagonal matrix, where φ m,ns = e jθm,n s is the phase shift of the n s th element on the mth sub-surface; h k,m ∈ C Ns×1 is the channel vector between the mth sub-surface and the kth user; n is the additive white Gaussian noise (AWGN) following the distribution CN (0, σ 2 ).
It is worth pointing out that two kinds of channel models in THz massive MIMO systems are considered: the theoretical Saleh-Valenzuela channel model and the practical 3GPP channel model, which will be discussed in detail in Subection II-B.
Considering the received signals {y k } K k=1 for all K users, the received signal y = [y 1 , y 2 , · · · , y K ] T can be rewritten as where To maximize the spectral efficiency of the RIS-based hybrid precoding architecture, the digital precoding matrix F and the analog beamforming matrix Φ in (2) should be jointly designed, which will be discussed in Subsection II-C.

B. Channel models
In this part, the theoretical Saleh-Valenzuela channel model and the practical 3GPP channel model for THz communication will be introduced.

1) Saleh-Valenzuela channel model:
We first consider the typical theoretical Saleh-Valenzuela channel model in THz massive MIMO systems [22], where the channel vector h k,m in (1) be presented as where L k,m is the number of multipath between the mth sub-surface and the kth user, α k,m ) ∈ C Ns×1 is the array response vector. When we consider the widely used uniform planar array (UPA) with N s1 antenna elements in the horizontal direction and N s2 antenna elements in the vertical direction (N s = N s1 × N s2 ), the array response vector can be presented as where where λ is the signal wavelength, d 1 (d 2 ) represents the element spacing in the horizontal (vertical) direction, and I (n) = {0, 1, · · · , n − 1}.
2) 3GPP channel model: We also consider the practical 3GPP channel model in this paper.
where h k,n (τ, t) is the channel between the nth elements on RIS and the kth user, which can be presented as: where K R is the Ricean K-factor, δ(·) is the Dirac's delta function, h LOS k,n,1 and h NLOS  (10) and the parameters are shown in [23].
The NLOS channel component h NLOS k,n can be presented as: where 2 multiple clusters channel h NLOS k,n,p,j (t) (p = 1, 2) and P − 2 single cluster channel h NLOS k,n,p (t) (p = 3, 4, · · · , P ) are considered in this paper, which are shown as (12) and (13). The parameters of the NLOS channel component are presented in [23].

C. Problem formulation
Based on the system model and two channel models mentioned above, the formulation of hybrid precoding problem is discussed as follow. Our aim is to design the RIS-based hybrid precoding by maximizing the achievable sum-rate R, which can be described as where γ k is the signal-to-interference-plus-noise ratio (SINR) of the kth user, which is expressed as where f k is the kth column of digital precoding matrix F.
As mentioned above, the aim is to maximize the achievable sum-rate R by designing the optimal the digital precoding matrix F opt and analog beamforming matrix Φ opt . The optimization problem can be formulated as where F denotes the set consisting of all possible analog beamforming matrices, and ρ is the maximal transmit power. Generally, due to the practical hardware implementation, RIS can only achieve discrete phase shifts [16]. We consider the 1-bit phase shift of RIS for the proposed RISbased hybrid precoding architecture, i.e., θ m,ns is either 0 or π, which can be easily implemented by the diodes with very low power and cost [16]. In this case, each diagonal element of Φ in (4) should be selected from {−1, +1}.
Due to the non-convex constraint C 2 , the optimization problem (16) is non-convex. Thus, it is not a trivial task to find out the optimal solution to (16). In the next section, inspired by deep learning, we will propose an optimization algorithm to achieve the near-optimal performance with low complexity.

III. DEEP LEARNING BASED HYBRID PRECODING DESIGN
In this section, the hybrid precoding optimization problem (16) is reformulated first. Then we propose the DL-MDC algorithm to solve the reformulated problem. Next, we provide the complexity analysis of the DL-MDC algorithm. Finally, the insight of the idea of the DL-MDC algorithm for some other problems for wireless communications is presented.

A. Reformulation of hybrid precoding optimization problem
The hybrid precoding optimization problem (16) can be completed in two steps: digital precoding optimization and analog beamforming optimization. For the optimization of digital precoding, the low-complexity zero forcing (ZF) algorithm [29] can be used based on the effective channel H eq = HΦG, if the analog beamforming matrix Φ has been achieved, i.e., digital precoding matrix F can be computed as: the optimization of analog beamforming is non-convex. The optimal solution to this non-convex problem is the exhaustive search algorithm, which however suffers from the unaffordable computational complexity in THz massive MIMO systems. For example, when the number of RIS elements N is 128, the search space is 2 128 ≈ 3.4 × 10 38 , which is too large to be realized in practice. Some iterative search methods [30] with reduced complexity can be used to approach the optimal exhaustive search algorithm. However, the complexity of existing iterative search methods is still high for THz massive MIMO systems with numerous RIS elements. To this end, with new data samples is tested. The proposed DL-MDC algorithm with four steps will be discussed in detail in the next Subsection III-B.

B. Proposed DL-MDC algorithm
As mentioned before, the proposed DL-MDC algorithm, whose pseudo code is shown in Algorithm 1, is composed of four steps.
1) Parallel DNN system model: The first step of our scheme is to establish the DNN model.
Through our extensive simulations, we find that the model of multiple DNNs is more stable and DNNs are utilized to solve the multiple binary classification problems independently as shown in Fig. 2, where each DNN has only one output, which responds to one diagonal element of the analog beamforming matrix Φ. In other word, each binary classification problem is solved by a particular DNN. In this way, all DNNs in the parallel DNN system can be trained and used simultaneously, so the runtime will be reduced substantially.
In the proposed parallel DNN system, a nonlinear activation function named sigmoid, i.e., sigmoid (x) = 1 1+e −x [33], is adopted in the output layer. Particularly, the output of the sigmoid function ranges from 0 to 1, and the threshold is set as 0.5 to obtain the final binary classification result. Meanwhile, for the hidden layers of each DNN in the parallel DNN system, we choose ReLU function, i.e., ReLU (x) = max (0, x) [33], as the activation function to capture the characteristics of the data samples. Here "labels" are the expected outputs of the parallel DNN system, which are used to calculate the loss function, which will be discussed in the next step of training stage. Specifically, the data samples are generated as follows. First, the channel matrix H (q) is generated according to the theoretical Saleh-Valenzuela [22] or the practical 3GPP channel model [23] as the input of the parallel DNN system, where q denotes the index of the data sample. Secondly, based on the channel matrix H (q) , we run the traditional hybrid precoding algorithm to generate the corresponding analog beamforming matrix Φ (q) , whose entries will be used as the labels of the parallel DNN system. As mentioned before, as 1-bit phase shift of RIS is considered for the proposed RIS-based hybrid precoding architecture in this paper, the diagonal entries in Φ (q) are either 1 or -1. Next, the input H (q) and the corresponding label Φ (q) are combined as the training tuple H (q) , Φ (q) . It should be noted that we use the ZF algorithm to obtain the digital precoding matrix after the analog beamforming matrix has been achieved [34], where the equivalent channel used by the ZF algorithm is H (q) Φ (q) G (q) .
T and V are used to denote the indices of data samples of these two sample sets, respectively.
As suggested in [35], 80% of generated data samples will be assigned to the training sample set, and 20% to the validation sample set. These data samples will be used for training the weights of the parallel DNN system, which will be discussed in the following step.
3) Training stage: Before training the parallel DNN system, the neuron weights are initialized by the truncated normal distribution for better training performance [32]. Additionally, to mine more essential features to express the mapping relationship between the channel matrix H (q) and analog beamforming matrix Φ (q) , we also preprocess the data samples. More specifically, since the key goal of analog beamforming is to generate directional beams, the channel direction information embedded in the phase of each element in the channel matrix H (q) , is more important than the channel gain information embedded in the amplitude of each element in the channel matrix H (q) . Therefore, the phase θ is extracted as the new input of the parallel DNN system. In addition, for the label Φ (q) , as the sigmoid function with the output range [0, 1] is adopted in the output layer, the label of the parallel DNN system, which is either 1 or -1, should be mapped to 0 or 1 to calculate the loss function [33]. Therefore, we use 0.5 * Diag Φ (q) + 0.5 with the same output range [0, 1], as the new label, which is denoted as {φ (q) n }, to calculate the loss function [33]. The updated training tuple after data samples preprocessing is denoted as θ n } and the actual output of the parallel DNN system as the loss function for training, which is shown as where Loss n denotes the loss function of the nth DNN, y n denotes the actual output of the nth DNN in the parallel DNN system.
Based on the loss function (18), we use the RMSprop training algorithm [32] to optimize the weights of all neurons in the parallel DNN system. The decay rate of the RMSprop we choose is 0.9, as suggested in [35]. Meanwhile, there are some other parameters in the RMSprop algorithm, such as learning rate, batch-size, and dropout. In order to figure out the suitable parameters of the RMSprop algorithm, we employ the cross-validation mechanism in the training stage. The details of cross-validation mechanism are explained as follows.
First, θ that the current parallel DNN system is not complex enough in scale to describe the considered non-convex problem. Therefore, the dropout should be reduced. Based on these new adjusted parameters of the RMSprop training algorithm, the parallel DNN system can be trained again by employing the cross-validation mechanism. The above parameter adjustment and the retraining process will stop until the MSEs of the validation and training sample sets converge to a threshold, i.e., 1%, which means the parallel DNN system has been trained well with suitable parameters.

4)
Testing stage: As mentioned in Data samples generation, the parallel DNN system is trained with a large number of data samples, which contain the channel matrices across different time and space, to ensure the generalization ability. To verify the generalization capability of the parallel DNN system, we test the trained parallel DNN system by using test data samples following the same distribution as the those in the step of data samples generation. Specifically, we first pass each new channel matrix H through the trained parallel DNN system to get the outputs, which are the prediction results (the analog beamforming matrix) of the trained parallel DNN system. Then, the prediction results of the parallel DNN system are compared with the labels obtained from the traditional hybrid precoding algorithm to calculate the prediction accuracy of the parallel DNN system. l p l p+1 always holds. Thus, the proposed algorithm has much lower complexity than the optimal exhaustive search algorithm.

C. Complexity analysis
Additionally, the complexity of the proposed DL-MDC algorithm is comparable to that of the iterative search methods for hybrid precoding. For example, the cross entropy optimization (CEO) algorithm [30], which is applied as the traditional hybrid precoding algorithm with good performance in this paper, has the complexity O(ISNK 2 ), where the number of iterations I and the number of candidates S are the parameters of the CEO algorithm. However, after the offline training of the parallel DNN system, the runtime of the parallel DNN system is much less than that of the CEO algorithm, which will be verified by simulations in Section IV.

D. Insights from the proposed DL-MDC algorithm
In this paper, we reformulate the optimization problem with non-convex constraint into multiple discrete classification problems, and utilize the parallel DNN system as the efficient classifiers accordingly. This idea can be applied to solve some other problems for wireless communications.
For example, the distance-frequency dependent property for THz communication [36], which means the different bandwidths of transmission windows created by THz molecular absorption change drastically for different communication distances, will motivate the design of carrier assignment. The carrier assignment is to figure out the available carriers for transmission. For each carrier, whether the carrier can be used to transmit signal is a binary classification problem.
Therefore, this carrier assignment design problem can be also reformulated as the multiple binary classification problems and solved by the proposed DL-MDC algorithm, where the output of each DNN in the parallel DNN system is posterior probability of the carrier being used.
Moreover, instead of using raw data samples to train DNN directly, we preprocess the raw data samples based on the physical property of the hybrid precoding, i.e., the channel direction information is more important than the channel gain information for analog beamforming to generate directional beams. Through our extensive simulations, the prediction accuracy of the parallel DNN system trained with the processed data samples is better than that with raw data samples. This reminds us when applying deep learning techniques to solve some problems in wireless communication systems, instead of directly using the deep learning as a new tool, we can further improve the algorithm of deep learning, i.e., preprocessing the data samples or changing the activation function based on the specific problem, to achieve better performance.

IV. SIMULATION RESULTS
In this section, considering both the theoretical Saleh-Valenzuela channel model and the practical 3GPP channel model, the proposed DL-MDC algorithm for the proposed RIS-based hybrid precoding architecture is conducted for THz communication. The performance in terms of the prediction accuracy and runtime is evaluated via simulations. Moreover, the achievable sumrate comparison between the proposed DL-MDC algorithm and the traditional hybrid precoding algorithm is presented. We choose the CEO algorithm [30] as the traditional hybrid precoding algorithm, which is also utilized to generate the data samples for training the parallel DNN system. Note that although the CEO algorithm is used as example, other algorithms with different performance for hybrid precoding can be approximated with less runtime by the proposed DL-MDC algorithm.
We assume that the BS employs an RIS of N = 64 (or 128) passive elements with the element spacing d 1 = d 2 = λ/2 for the typical downlink THz massive MIMO system, and M = 4 RF chains are used to serve K = 4 users simultaneously. Thus, each sub-surface on the RIS consists of N s = 16 (or 32) passive elements.
In our simulation, the proposed DL-MDC hybrid precoding scheme and the CEO algorithm are implemented in Python 3.6.0 with TensorFlow 1.3.0. Each DNN in the parallel DNN system has one input layer, three hidden layers, and one output layer.

A. Simulation results in the Saleh-Valenzuela channel model
In the simulations based on Saleh-Valenzuela channel model, the channel h k,m is generated according to (2), and we assume: k,m and θ (l) k,m follow the uniform distribution U(−π, π) [37]. We consider that RIS and antenna feeder are integral parts of the transmitter, and the channel g m between the BS and RIS is assumed to be a all-one vector of size N s × 1 [21]. The first hidden layer of DNN in the parallel DNN system contains 256 neurons, and both the second and third hidden layers consist of 80 neurons.     (N = 64).
In order to show the performance of the parallel DNN system in solving classification problems, we present the prediction accuracy for phase shift of each element on RIS in the testing stage in Table I. The prediction accuracy is defined as the probability that the prediction result is the same as the CEO algorithm. As we have mentioned before, there are N elements on RIS, and each element is associated with one specific DNN in the parallel DNN system. Therefore, there are N prediction results as shown in Table I, where the average prediction accuracy is about 0.99 for all N RIS elements. It should be noted that, the prediction accuracy of each RIS element has a slight difference due to certain randomness of mini-batch gradient descent [33] in the training stage.    Table II.  Achievable sum-rate (bps/Hz) CEO algorithm Proposed DL-MDC algorithm AS algorithm [38] (a)    Meanwhile, both schemes significantly outperform from the AS-based hybrid precoding scheme.

B. Simulation results in the 3GPP channel model
It is clear from Subsection II-B that the 3GPP channel model of rich scattering environment is much more complicated than the typical theoretical Saleh-Valenzuela channel model. Therefore, for the parallel DNN system model with the same scale as mentioned in Subsection IV-A, mining the mapping relationship between the channel matrix H (q) generated by the 3GPP channel model and analog beamforming matrix Φ (q) is more difficult than that generated by the Saleh-Valenzuela channel model. In this case, the scale of the parallel DNN system based on the Saleh-Valenzuela channel model in Subsection IV-A needs to be expanded to approximate the mapping function of the channel matrix H (q) generated by the 3GPP channel model and analog beamforming matrix Φ (q) . Here, in the simulation based on the 3GPP channel model, the three hidden layers contain 512, 256, 128 neurons, respectively. of validation sample set converges to nearly 0.05, which is a little bit larger than that in Fig. 3.
Thus, the average prediction accuracy 0.94 is lower than the average prediction accuracy 0.99 in Fig. 3. The influence of this small difference in the average prediction accuracy between   Saleh-Valenzuela channel model and 3GPP channel model will be considered and discussed in simulation results in the following Fig.7. Therefore, the small difference in the average prediction accuracy shown in Fig. 6, will not affect the sum-rate performance of the proposed DL-MDC algorithm too much.

V. CONCLUSIONS
In this paper, we proposed a RIS-based hybrid precoding architecture for THz communication, where the energy-efficient RIS instead of the energy-hungry phased array was used to realize the analog beamforming of the hybrid precoding. In order to maximize the sum-rate of the users, the hybrid precoding matrix was carefully designed. Specifically, we reformulated the sum-rate optimization problem as multiple discrete classification problems because of the non-convex constraint of discrete phase shifts in RIS-based hybrid precoding architecture. Then, the DL-MDC hybrid precoding algorithm was proposed to solve the multiple discrete classification problems.
The simulation result showed that the proposed DL-MDC hybrid precoding algorithm has much lower runtime than the traditional hybrid precoding algorithm with negligible the achievable sumrate performance. Thus, the parallel DNN system utilized in the proposed DL-MDC algorithm can approximate the complex non-convex function of the traditional hybrid precoding algorithm well, which provides a reasonable trade-off between performance and complexity.