I have a model that produces output tensor of NaN’s, when the inference is done with Sentis. ORT produces tensor of floats. Can you please take a look what may be wrong.

Thanks! I was able to figure it out, the problem was `Softplus`

our implementation wasn’t numerically stable.

Pretty easy fix.

Do you want a workaround by having a custom op that overrides our implementation?

In any case the fix will be there for the upcoming version

Thank you! I would appreciate a workaround until you release the update.

By the way, do you have already an estimated release date for the next version?

You can check the `CustomLayer`

sample

```
[OpImport("Softplus")]
public class StableSoftplusLayer : IOpImporter
{
public void Import(Model model, OperatorNode node)
{
model.AddLayer(new StableSoftplus(node.Name, node.Inputs[0]));
}
}
```

and

```
[Serializable]
public class StableSoftplus : Layer
{
public override Tensor Execute(Tensor[] inputs, ExecutionContext ctx)
{
var X = inputs[0];
ctx.op.Log(new TensorFloat(1) + op.Exp(op.Sub(X)) + op.Clip(X, 0, float.maxValue);
}
```

@alexandreribard_unity Sorry, but there are errors in the code of StableSoftplus.Execute().

Should Softplus return: Log(Exp(x) + 1) ?

Yes, that’s the typical formula. But it’s not numerically stable for your model, hence the NANs.

The one listed above helped with numerical precision

I agree, but there are syntax errors in the following line (Sub with one parameter, unclosed parenthesis, …). That’s why I ask either for correct code, or for the math formula

```
ctx.op.Log(new TensorFloat(1) + op.Exp(op.Sub(X)) + op.Clip(X, 0, float.maxValue);
```

Ah sorry for the confusion

Here’s the forumla:

```
log(1+exp(-abs(x))) + max(x,0)
```

This is resolved after the update. Thank you!

now that’s what we like to hear