Open marwan116 opened 4 years ago
If your inflection point is fixed (i.e. with known input value), then this can be done with the sum of two PWL's. Our PWL layers are flat outside the rage defined by the input keypoints, so you can just split your original input keypoint list at the inflection point and use a different PWL for each part. If there is enough symmetry, you might be able to do this with a single 2 dimensional layer and a couple of negations.
If the inflection point is not fixed, then I think this can still be done with 3 PWL's with some caveats. The generic form might not have a trivial solution.
Depending on your usecase and if your date already partially looks like an s-curve, you might also want to look at wrinkle regularization (see used in action here: https://www.tensorflow.org/lattice/tutorials/shape_constraints#smoothing_calibrators). It penalizes the changes in the second derivative (https://www.tensorflow.org/lattice/api_docs/python/tfl/pwl_calibration_layer/WrinkleRegularizer).
Thank you so much for your prompt response:
Yes, I agree if the inflection point is known beforehand, then I can imagine how crafting a combination of 2 PWLs or a single 2D layer would be a good workaround ... I guess it would be nice to add this as one of the examples (to show how combining constrained PWL layers leads to more complex shape definitions)
That's a good idea. Might be a good tutorial to build various shape constraints using the current set of layers.
First off - Thank you so much for open sourcing Tensorflow lattice! It is great to make use of lattice interpolation to enforce predicate domain knowledge concerning monotonicity and convexity. Looking through the current documentation, I see it is possible to enforce an increasing and concave graph for diminishing returns, but what if I want to enforce an S-curve (i.e. an increasing convex curve with an inflection point that then turns concave)?