Q: Weighted binary cross entropy - create loss function I'm attempting to create a loss function to control penalization under certain situations. 

Basically, I want to penalize when the truth is $1$ but the prediction is $0$.
However, as far as my research went, since my output comes from a sigmoid activation unit, the range can be from $0 \rightarrow 1$. So I thought, I should have a linear formula for it. So first, I came up with this:
$$
{\rm loss} = \Big(atp + a\big((t-1)(p-1)\big)\Big) - (a - 1)\text{ and }a = -1
$$
where: $a$ is alpha, $t$ is the target / truth, and $p$ is the prediction.  
So, formally:
$$
{\rm loss} = \Big( \alpha\times{\rm target}\times{\rm prediction} + \alpha \times \big(({\rm target}-1) \times ({\rm prediction}-1)\big)\Big) - (\alpha - 1)  \\
\text{ and }  \\
\alpha = -1
$$
This loss formula creates the table below:

However, I'm stuck! How do I add a variable that will get the effect of penalization that I want?

A: It seems like the tensorflow documentation on weighted cross entropy with logits is a good resource, if its a classification case use the above. Any other case makes sure you have the weighted mask and multiple that value in the lost. Since the gradient have the same dimensionality with the output, the math for elementwise multiplication will work out. 
To be a little more specific the loss function looks like this:
$$
{\rm loss} = \Big(atp + a\big((t−1)(p−1)\big)\Big)−(a−1)
$$
but since we have the true label either $0$ or $1$, we can divide the loss function into two cases where gt is $0$ or $1$; that looks something like the binary cross entropy function. And the website linked above does exactly something like that where the loss function is penalizing the case where gt label is $1$ but the prediction is $0$. That penalty can be greater or smaller than $1$.  
