TSN implements time synchronization through IEEE 802.1AS protocol, and the performance of time synchronization is related to the frequency accuracy and stability of each TSN clock. However, the problems of clock drift and timestamp granularity error (TSGE) will degrade the network time synchronization performance. This paper analyzes the causes of time errors caused by network time synchronization, and puts forward the overall scheme to improve the performance of time synchronization. An intelligent compensation algorithm for clock drift is designed, which includes measuring node clock correlation data, training neural network, using neural network to make prediction and compensating time stamp. Experimental results show that the proposed algorithm is stable and accurate in time synchronization.