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

Function odeint

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

Integrate a system of ordinary differential equations. Solves the initial value problem for a non-stiff system of first order ODEs: ``` dy/dt = func(y, t), y(t[0]) = y0 ``` where y is a Tensor of any shape. For example: ``` # solve `dy/dt = -y`, corresponding to expone

(func,
           y0,
           t,
           rtol=1e-6,
           atol=1e-12,
           method=None,
           options=None,
           full_output=False,
           name=None)

Source from the content-addressed store, hash-verified

419
420
421def odeint(func,
422 y0,
423 t,
424 rtol=1e-6,
425 atol=1e-12,
426 method=None,
427 options=None,
428 full_output=False,
429 name=None):
430 """Integrate a system of ordinary differential equations.
431
432 Solves the initial value problem for a non-stiff system of first order ODEs:
433
434 ```
435 dy/dt = func(y, t), y(t[0]) = y0
436 ```
437
438 where y is a Tensor of any shape.
439
440 For example:
441
442 ```
443 # solve `dy/dt = -y`, corresponding to exponential decay
444 tf.contrib.integrate.odeint(lambda y, _: -y, 1.0, [0, 1, 2])
445 => [1, exp(-1), exp(-2)]
446 ```
447
448 Output dtypes and numerical precision are based on the dtypes of the inputs
449 `y0` and `t`.
450
451 Currently, implements 5th order Runge-Kutta with adaptive step size control
452 and dense output, using the Dormand-Prince method. Similar to the 'dopri5'
453 method of `scipy.integrate.ode` and MATLAB's `ode45`.
454
455 Based on: Shampine, Lawrence F. (1986), "Some Practical Runge-Kutta Formulas",
456 Mathematics of Computation, American Mathematical Society, 46 (173): 135-150,
457 doi:10.2307/2008219
458
459 Args:
460 func: Function that maps a Tensor holding the state `y` and a scalar Tensor
461 `t` into a Tensor of state derivatives with respect to time.
462 y0: N-D Tensor giving starting value of `y` at time point `t[0]`. May
463 have any floating point or complex dtype.
464 t: 1-D Tensor holding a sequence of time points for which to solve for
465 `y`. The initial time point should be the first element of this sequence,
466 and each time must be larger than the previous time. May have any floating
467 point dtype. If not provided as a Tensor, converted to a Tensor with
468 float64 dtype.
469 rtol: optional float64 Tensor specifying an upper bound on relative error,
470 per element of `y`.
471 atol: optional float64 Tensor specifying an upper bound on absolute error,
472 per element of `y`.
473 method: optional string indicating the integration method to use. Currently,
474 the only valid option is `'dopri5'`.
475 options: optional dict of configuring options for the indicated integration
476 method. Can only be provided if a `method` is explicitly set. For
477 `'dopri5'`, valid options include:
478 * first_step: an initial guess for the size of the first integration

Callers

nothing calls this directly

Calls 4

_check_input_typesFunction · 0.85
_dopri5Function · 0.85
absClass · 0.50
name_scopeMethod · 0.45

Tested by

no test coverage detected