In recent years, tunnel boring machines (TBMs) have been widely used in tunnel construction. However, the TBM control parameters set based on operator experience may not necessarily be suitable for certain geological conditions. Hence, a method to optimize TBM control parameters using an improved loss function-based artificial neural network (ILF-ANN) combined with quantum particle swarm optimization (QPSO) is proposed herein. The purpose of this method is to improve the TBM performance by optimizing the penetration and cutterhead rotation speeds. Inspired by the regularization technique, a custom artificial neural network (ANN) loss function based on the penetration rate and rock-breaking specific energy as TBM performance indicators is developed in the form of a penalty function to adjust the output of the network. In addition, to overcome the disadvantage of classical error backpropagation ANNs, i.e., the ease of falling into a local optimum, QPSO is adopted to train the ANN hyperparameters (weight and bias). Rock mass classes and tunneling parameters obtained in real time are used as the input of the QPSO-ILF-ANN, whereas the cutterhead rotation speed and penetration are specified as the output. The proposed method is validated using construction data from the Songhua River water conveyance tunnel project. Results show that, compared with the TBM operator and QPSO-ANN, the QPSO-ILF-ANN effectively increases the TBM penetration rate by 14.85% and 13.71%, respectively, and reduces the rock-breaking specific energy by 9.41% and 9.18%, respectively.