<p>you can write is as sum(A*B)/(sum(A^2)+sum(B^2)). refer to <a href="https://arxiv.org/abs/1606.04797" rel="nofollow">https://arxiv.org/abs/1606.04797</a></p>
Custom loss function for lasagne/ theano
<p>I am trying to create a custom loss function for use in lasagne. </p>

<p>I would like to use Sorensen-dice coefficient which I have written with numpy, and use for evaluation like so:</p>

<pre><code>np.sum(np.logical_and(preds == num_labs, labels == num_labs)))*2/ (np.sum(preds == num_labs) + np.sum(labels == num_labs)
</code></pre>

<p>Which is doing:</p>

<p>Dice =  (2*|X &amp; Y|)/ (|X|+ |Y|)</p>

<p>I am now trying to implement this in theano, unsure how feasible it is. </p>

<p>Is it possible to use this as a loss function? I would like to use it as I am segmenting volumes but I as this should be differentiable for back propagation, how can I change this?</p>

<p>Any thoughts?</p>