Drug–target interaction (DTI) identification is a complex process that is time-consuming, costly and frequently inefficient, with a low success rate, especially with wet-experimental methods. The prediction of DTI by calculational methods is an effective way to solve this problem. However, most existing methods regard drug–target pairs with unknown interaction relationship as negative samples, that the false negative samples will affect the AUC and AUPR evaluation, leading to performance misjudgment. Therefore, in this paper, a new DTI prediction method, DTI-HAN, is proposed to overcome the shortcoming and further improve the predictive performance. In the drug and target feature representation learning stage, this method constructs a drug–target heterogeneous network based on similarity and interaction relationship, and establishes meta-path, node-level and semantic-level bi-attention mechanism. To avoid introducing false negative examples, an improved loss function based only on known edges is proposed. In the DTI prediction stage, feature projection and fuzzy theory are introduced, and membership distribution function is estimated only depended on positive samples. Compared with the DTI prediction methods, DTI-GAT, DTI-GCN and DTI-GraphSAGE, as well as BLM, DTHybrid, SCMLKNN and FPSC-DTI, the experimental results on Enzyme, GPCR, Ion Channel and Nuclear Receptor 4 datasets showed that the DTI-HAN method can greatly improve the AUC and AUPR values on at least 3 datasets to each method. Furthermore, the novel top 100-pair of DTIs prediction were verified by KEGG, DrugBank, ChEMBL and SuperTarget databases, and obtained 21, 48, 61 and 28 validation records, respectively. The top-5 remaining unverified DTIs were performed molecular docking with AutoDock Vina, and the results showed that these drugs and targets have good binding properties. The code and data are available at https://github.com/Yu123456/DTI-HAN.