layers
Custom layers that are needed for the various models.
- bpreveal.layers.linearRegression(**kwargs)
A linear regression layer that’s compatible with shap.
Implements the following formula:
out = input * slope + offset
where slope and offset are two (scalar) parameters.
Note that although this is a function, it behaves like a normal Keras layer class and you create it like this:
regression = bpreveal.layers.LinearRegression(name="oct4_regression")(regressionInput)
- Parameters:
kwargs – Passed to the keras Layer initializer.
- Returns:
A function that you can call with a Keras layer as input, like a normal Keras Layer class.
- Return type:
A function taking a tensor and returning a tensor.
- class bpreveal.layers.CountsLogSumExp(*args, **kwargs)
A simple layer that wraps keras.ops.logaddexp.
- Parameters:
args (Any)
kwargs (Any)
- Return type:
Any
- call(inp1, inp2)
Calculate logsumexp.
- Parameters:
inp1 (Tensor) – The first value
inp2 (Tensor) – The second value
- Returns:
log(exp(inp1) + exp(inp2)).
- Return type:
Tensor
- get_config()
Used to make this class deserializable.
- Returns:
A configuration dictionary. There is no custom data in it.
- Return type:
dict