Skip to content

Instantly share code, notes, and snippets.

@ravnoor
Forked from prhbrt/Keras.ipynb
Created April 24, 2017 02:38
Show Gist options
  • Save ravnoor/a8d26c485cd39c1d9dd21af7c27ac232 to your computer and use it in GitHub Desktop.
Save ravnoor/a8d26c485cd39c1d9dd21af7c27ac232 to your computer and use it in GitHub Desktop.
V-Net in Keras and tensorflow
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@jizhang02
Copy link

hello,
I run U-Net using dice loss, but the predicted images are all white. Do you know what's wrong?
def dice_coef(y_true, y_pred):
smooth = 1
y_true_f = K.flatten(y_true)
y_pred_f = K.flatten(y_pred)
intersection = K.sum(y_true_f * y_pred_f)
return (2. * intersection +smooth) / (K.sum(y_true_f) + K.sum(y_pred_f) +smooth)

def dice_coef_loss(y_true, y_pred):
print("dice loss")
return 1-dice_coef(y_true, y_pred)
....
model.compile(optimizer = Adam(lr = 1e-5), loss = dice_coef_loss, metrics = ['accuracy'])

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment