MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / _optimal_step_size

Function _optimal_step_size

tensorflow/contrib/integrate/python/ops/odes.py:216–233  ·  view source on GitHub ↗

Calculate the optimal size for the next Runge-Kutta step.

(last_step,
                       error_ratio,
                       safety=0.9,
                       ifactor=10.0,
                       dfactor=0.2,
                       order=5,
                       name=None)

Source from the content-addressed store, hash-verified

214
215
216def _optimal_step_size(last_step,
217 error_ratio,
218 safety=0.9,
219 ifactor=10.0,
220 dfactor=0.2,
221 order=5,
222 name=None):
223 """Calculate the optimal size for the next Runge-Kutta step."""
224 with ops.name_scope(name, 'optimal_step_size', [last_step,
225 error_ratio]) as scope:
226 error_ratio = math_ops.cast(error_ratio, last_step.dtype)
227 exponent = math_ops.cast(1 / order, last_step.dtype)
228 # this looks more complex than necessary, but importantly it keeps
229 # error_ratio in the numerator so we can't divide by zero:
230 factor = math_ops.maximum(1 / ifactor,
231 math_ops.minimum(error_ratio**exponent / safety,
232 1 / dfactor))
233 return math_ops.div(last_step, factor, name=scope)
234
235
236def _abs_square(x):

Callers 1

Calls 5

maximumMethod · 0.80
minimumMethod · 0.80
divMethod · 0.80
name_scopeMethod · 0.45
castMethod · 0.45

Tested by

no test coverage detected