Link Search Menu Expand Document

getJacobian()

Solve jacobian matrix for a given expression expr, input tensor x and varaibles

\[jac_{ij} = \frac{d(expr(x[i], var[j]))}{d(var[j])}\]

Import

import * as datacook from '@pipcook/datacook';
const { getJacobian } = datacook.Linalg;

Syntax

getJacobian(expr: (tf: any, x: tf.Tensor, ...coeffs: tf.Variable[]) => tf.Scalar,
  x: tf.Tensor, ...coeffs: tf.Variable[]): { values: tf.Tensor, jacobian: tf.Tensor}

Parameters

Parametertypedescription
expr(tf: any, x: tf.Tensor, …coeffs: tf.Variable[]) => tf.Scalarexpression function for x[i] and varaibles, return value should be a scalar
xTensorinput tensor of shape [n, ….]
coeffstf.Variable[]array of coefficients