import keras.backend as K
from keras.optimizers import Adam
from keras.losses import binary_crossentropy
## intersection over union
def IoU(y_true, y_pred, eps=1e-6):
#print(y_true)
if np.max(y_true) == 0.0:
return IoU(1-y_true, 1-y_pred) ## empty image; calc IoU of zeros
intersection = K.sum(y_true * y_pred, axis=[1,2,3])
union = K.sum(y_true, axis=[1,2,3]) + K.sum(y_pred, axis=[1,2,3]) - intersection
return -K.mean( (intersection + eps) / (union + eps), axis=0)
我遇到以下错误
NotImplementedError:无法转换符号张量 (up_sampling2d_5_target:0)转换为numpy数组。
https://www.kaggle.com/hmendonca/u-net-model-with-submission
但是当我在这里运行它时,它不会出现错误
这是keras版本的问题吗?我不确定有什么区别?
import keras print(keras.__version__) 2.3.1