Most of the existing task offloading methods in edge computing environments do not fully utilize the processing capabilities of cloud servers and have high computational complexity, making them unsuitable for real-time processing tasks. To address this problem, we propose a cloud–edge–end collaborative task offloading method based on deep learning methods, combining Convolutional Neural Networks (CNN), Long Short-Term Memory (LSTM), and attention mechanisms. This method models the total cost of the cloud–edge–end collaboration system as a weighted sum function of the time delay and energy consumption of task execution. Then, with the objective of minimizing the total cost of the system, the task offloading problem is formulated as a mixed-integer joint optimization problem with offloading decision and bandwidth allocation, and two subproblems are decomposed from the optimization problem: one focuses on offloading decision and the other on bandwidth allocation. A CNN-LSTM-Attention neural network-based method is proposed to solve the optimal offloading decision efficiently. Based on this, the differential evolution algorithm is used to generate the optimal bandwidth allocation, resulting in efficient task offloading. The simulation experiment results demonstrate that our method enhances system performance and reduces the overall cost of the system, which is significantly better than existing methods.