Beamforming technique can effectively improve the spectrum utilization of multi-antenna systems, while the dirty-paper coding (DPC) technique can reduce inter-user interference. In this letter, we aim to maximize the weighted sum-rate under power constraint in a multiple-input-single-output (MISO) system with the DPC. However, the existing methods of beamforming optimization mainly rely on customized iterative algorithms, which have high computational complexity. To address this issue, by utilizing the deep learning technique and the uplink-downlink duality, and carefully exploring the optimal solution structure, we devise a beamforming neural network (BFNNet), which includes a deep neural network module and a signal processing module. Besides, we use the modulus of the channel coefficients as the input of deep neural network, which reduces the input size. Simulation results show that a well-trained BFNNet can achieve near-optimal solutions, while significantly reducing computational complexity