where TP are the true positives, FP false positives and FN false negatives. We can see that DC≥IoU.
The dice coefficient can also be defined as a loss function:
DL(p,^p)=2⟨p,^p⟩∥p∥22+∥^p∥22
where p∈{0,1}n and 0≤^p≤1.
defdice_loss(y_true,y_pred):numerator=2*tf.reduce_sum(y_true*y_pred)# some implementations don't square y_preddenominator=tf.reduce_sum(y_true+tf.square(y_pred))returnnumerator/(denominator+tf.keras.backend.epsilon())
Since p is either 1 or 0, the numerator will always be one times the predicted probability of the foreground pixel (1). Hence, when p is a background pixel (0), the numerator will be 0.
Tversky loss
Tversky loss (TL) is a generalization of Dice loss. TL adds a weight to FP and FN.
which is just Dice loss. In the paper [4], the authors square the predicted probability in the denominator, but e.g. the paper [5]keeps the term as it is.
DL and TL simply relax the hard constraint ^p∈{0,1}n in order to have a function on the domain [0,1]. The paper [6] derives instead a surrogate loss function.
An implementation of Lovász-Softmax can be found on github. Note that this loss requires the identity activation in the last layer. A negative value means class A and a positive value means class B.
In Keras the loss function can be used as follows:
[1] S. Xie and Z. Tu. Holistically-Nested Edge Detection, 2015.
[2] T.-Y. Lin, P. Goyal, R. Girshick, K. He, and P. Dollar. Focal Loss for Dense Object Detection, 2017.
[3] O. Ronneberger, P. Fischer, and T. Brox. U-Net: Convolutional Networks for Biomedical Image Segmentation, 2015.
[4] F. Milletari, N. Navab, and S.-A. Ahmadi. V-Net: Fully Convolutional Neural Networks for Volumetric Medical Image Segmentation, 2016.
[5] S. S. M. Salehi, D. Erdogmus, and A. Gholipour. Tversky loss function for image segmentation using 3D fully convolutional deep networks, 2017.
[6] M. Berman, A. R. Triki, M. B. Blaschko. The Lovász-Softmax loss: A tractable surrogate for the optimization of the intersection-over-union measure in neural networks, 2018.
Generate ssh key in local client. ssh-keygen -o -b 2048 -t rsa Then generate the key in /home/demo/.ssh/id_rsa and get the cotent. cat /home/demo/.ssh/id_rsa.pub ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDb/aQqEeRt82oMweTq2g2MBV5q+imeglCtPQKGPfBIFTxmoltZEukb8/iC0+ljkfTGTrkR3GRSqmdMz4lU3DS3nSiZ5KqZbFZJ/kOzHF+J8gsyce3n4Tt+OSwVeRtJ2O2mnCWmYonVfNdUuxDXb29C9j/el4wbDu0G0DshtdQ608svj3zyIvdkStnmv2P9DqWUQjS3VUh9dYTtZoamKFitIG5qgXL9//6hZCPGRuOnlnhtvoU163a75MEdY7OofV/UI9OgFe843XXOKYLsWNg/ySxb2qDhUmVU1qNDhcb/qKtMzHo5vpI3uyD7J52OaTu7TsPmEC3546FepM7nw+KF me@mymachine
ssh to gcr-sdb ssh FAREAST.xxx@gcr-sdb
copy the contents of the public SSH key you generated in the previous section into your /home/$(whoami|cut -d. -f2)/.ssh/authorized_keys file on gcr-sdb. cat << EOF >> /home/myalias/.ssh/authorized_keys ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDb/aQqEeRt82oMweTq2g2MBV5q+imeglCtPQKGPfBIFTxmoltZEukb8/iC0+ljkfTGTrkR3GRSqmdMz4lU3DS3nSiZ5KqZbFZJ/kOzHF+J8gsyce3n4Tt+OSwVeRtJ2O2mnCWmYonVfNdUuxDXb29C9j/el4wbDu0G0DshtdQ608svj3zyIvdkStnmv2P9DqWUQjS3VUh9dYTtZoamKFitIG5qgXL9//6hZCPGRuOnlnhtvoU163a75MEdY7OofV/UI9OgFe843XXOKYLsWNg/ySxb2qDhUmVU1qNDhcb/qKtMzHo5vpI3uyD7J52OaTu7TsPmEC3546FepM7nw+KF me@mymachine EOF
Log out and re-log into your Linux sandbox host, use the same username format used to SSH into gcr-sdb.
Or write a script ssh -i /home/usr/.ssh/id_rsa usr@remote_machine