zhixuhao / unet

unet for image segmentation
MIT License
4.6k stars 2k forks source link

Can I customize the loss function? #137

Open AbnerAI opened 5 years ago

AbnerAI commented 5 years ago

Hi,ZhiXuHao: good evening! I found that the loss function here just passes a loss function name, so I want to know if I can completely customize the loss function? model.compile(optimizer=Adam(lr=1e-4), loss='binary_crossentropy', metrics=['accuracy'])

edwinb-ai commented 5 years ago

Hey @AbnerAi

so I want to know if I can completely customize the loss function?

Yes, you can. As this is a Keras implementation you can use the Keras API to define custom metrics as well as losses.

For example, here is a question of an implementation of the Jaccard index, as well as the loss, in Keras. You can then pass the name of the loss to the model and compile it.

ThinhNgVhust commented 3 years ago

I think we should use (loss='mse', optimizer='adam') . Because Unet is likely kind of Autoencoder huh?