losses
Defines the Multinomial NLL loss and the adaptive counts loss.
These are derived from the basepairmodels repository, which is licensed under
an MIT license. You can find a copy at etc/basepairmodels_license.txt.
- bpreveal.losses.multinomialNll(trueCounts, logits)
The heart of what makes BPNet great - the loss function for profiles.
- Parameters:
trueCounts (tensorflow.Tensor) – The experimentally-observed counts. Shape
(batch-size x output-length x num-tasks)logits (tensorflow.Tensor) – The logits that the model is currently emitting. Shape
(batch-size x output-length x num-tasks)
- Returns:
A scalar representing the profile loss of this batch.
- Return type:
float
- bpreveal.losses.weightedMse(weightTensor)
Loss for the adaptive counts loss weight.
Given a weight tensor (a tensorflow Variable of shape (1,)) return a loss function that calculates mean square error and multiplies the error by the weight. This is used to implement the automatic counts weight algorithm.
- Parameters:
weightTensor (tensorflow.Variable) – The tensor that will be adjusted by the dynamic counts loss weight algorithm.
- Returns:
A loss function.
- Return type:
Callable
- bpreveal.losses.dummyMse(yTrue, yPred)
Used for loading models. If you’re going to train, you have to create a weightedMse, since this one has no loss weight to it. But if you’re just predicting, you can pass this function to custom_objects when you load a BPReveal model Always returns nan, so that if you do accidentally use it, all of your values will be poisoned.
- Parameters:
yTrue (tensorflow.Tensor)
yPred (tensorflow.Tensor)
- Return type:
float