问题 AttributeError: module ‘tensorflow’ has no attribute ‘py_func’ 原因 tf1升到tf2带来的的问题 解决方案 把tf.py_func改成tf.compat.v1.pyfunc def auroc(y_true, y_pred): return tf.compat.v1.py_func(roc_auc_score, (y_true, y_pred), tf.double)