torch.tx.grad
function grad(pattern: string, variable: string): stringCompute the symbolic derivative of a pattern with respect to a variable.
Parameters
patternstring- The expression pattern to differentiate
variablestring- The variable name to differentiate with respect to
Returns
string– A pattern string representing the derivativeExamples
grad('x ** 2', 'x') // Returns: '2 * x'
grad('sin(x)', 'x') // Returns: 'cos(x)'
grad('x * y', 'x') // Returns: 'y'
grad('sigmoid(x)', 'x') // Returns: 'sigmoid(x) * (1 - sigmoid(x))'