def aurocc(y_正确,y_预测): 返回tf.py_func(roc_auc_分数,(y_真,y_pred))
adam=keras.optimizers.adam(lr=0.0001) compile(优化器=adam,loss='classifical\u crossentropy',metrics=[aurocc]) model.fit(输入、标签、验证\u split=0.33、epochs=10、verbose=1、callbacks=callbacks)
AttributeError:在用户代码中:
/usr/local/lib/python3.7/dist-packages/keras/engine/training.py:830 train_function *
return step_function(self, iterator)
/usr/local/lib/python3.7/dist-packages/keras/engine/training.py:813 run_step *
outputs = model.train_step(data)
/usr/local/lib/python3.7/dist-packages/keras/engine/training.py:775 train_step *
self.compiled_metrics.update_state(y, y_pred, sample_weight)
/usr/local/lib/python3.7/dist-packages/keras/engine/compile_utils.py:457 update_state *
metric_obj.update_state(y_t, y_p, sample_weight=mask)
/usr/local/lib/python3.7/dist-packages/keras/metrics.py:169 decorated *
update_op = update_state_fn(*args, **kwargs)
/usr/local/lib/python3.7/dist-packages/keras/metrics.py:155 update_state_fn *
return ag_update_state(*args, **kwargs)
/usr/local/lib/python3.7/dist-packages/keras/metrics.py:641 update_state *
matches = ag_fn(y_true, y_pred, **self._fn_kwargs)
<ipython-input-46-e104431197fe>:2 aurocc *
return tf.py_func(roc_auc_score, (y_true, y_pred))
AttributeError: module 'tensorflow.compat.v2' has no attribute 'py_func'
TF2中已弃用并删除了此名称
tf.compat.v1.py_func
,但您可以改用tf.numpy_function
之前:(在Tensorflow 2.x中显示警告)
输出:
之后:
输出:
有关更多详细信息,请参阅此link
相关问题 更多 >
编程相关推荐