derivative

How do I use 1D gradients to compute a 2D Sobel in OpenCV with a different vector norm?

How do I use 1D gradients to compute a 2D Sobel in OpenCV with a different vector norm? Question: OpenCV uses an implementation of a Sobel operator defined here (details here). In this implementation, the horizontal derivative is generated, then the vertical derivative is generated, then the gradient is computed as the L2 norm of …

Total answers: 3

TypeError for derivative function

TypeError for derivative function Question: I used sympy to find derivative of a function. ( )= −5+√(4− ^2) import sympy def f_derivative(x): x = sympy.Symbol(‘x’) f = x – 5 + (4 – x**2)**0.5 derivative_f = f.diff(x) derivative_f = sympy.lambdify(x, derivative_f) print(derivative_f(1)) f_derivative(1) assert f_derivative(1) – 0.42264973 < 1e-5 However, there is an error when …

Total answers: 2

Derivative using Numpy or Other Library for lambda sin function

Derivative using Numpy or Other Library for lambda sin function Question: So i have this newton optimation problem where i must found the value f'(x) and f”(x) where x = 2.5 and the f = 2 * sin(x) – ((x)**2/10) for calculating, but i tried using sympy and np.diff for the First and Second Derivative …

Total answers: 1

Tensorflow: x – reduce_mean(x) has gradient 0

Tensorflow: x – reduce_mean(x) has gradient 0 Question: I was observing gradients when I noticed that the gradient of subtracting one’s axis’ mean is zero. I think this is very counter-intuitive because gradient = 0 normally means the function is constant. Can anyone explain intuitively why the gradient here is zero? import tensorflow as tf …

Total answers: 1

How do I compute derivative of a lambda expression using Sympy?

How do I compute derivative of a lambda expression using Sympy? Question: How to compute a lambda expression’s derivative ? For example: func = lambda x: x ** 3 – 3 * x ** 2 … # the code … derived_func = lambda x: 3 * x ** 2 – 6 * x Asked By: …

Total answers: 2

Sympy returns log instead of ln

Sympy returns log instead of ln Question: I have this equation: import sympy as sp x = sp.Symbol(‘x’, real = True) fx = sp.log(x,3) sp.diff(fx, x) Sympy returns: 1/(x*log(3)) Sympy should return: 1/(x*ln(3)) Why is Sympy returning the log function rather than the natural log function? Asked By: vic || Source Answers: From here: Note: …

Total answers: 2

Compute a Jacobian matrix from scratch in Python

Compute a Jacobian matrix from scratch in Python Question: I’m trying to implement the derivative matrix of softmax function (Jacobian matrix of Softmax). I know mathematically the derivative of Softmax(Xi) with respect to Xj is: where the red delta is a Kronecker delta. So far what I have implemented is: def softmax_grad(s): # input s …

Total answers: 3