calculus

Derivative of a softmax function explanation

生来就可爱ヽ(ⅴ<●) 提交于 2020-01-11 16:19:42
问题 I am trying to compute the derivative of the activation function for softmax. I found this : https://math.stackexchange.com/questions/945871/derivative-of-softmax-loss-function nobody seems to give the proper derivation for how we would get the answers for i=j and i!= j. Could someone please explain this! I am confused with the derivatives when a summation is involved as in the denominator for the softmax activation function. 回答1: The derivative of a sum is the sum of the derivatives, ie: d

Derivative of a softmax function explanation

浪子不回头ぞ 提交于 2020-01-11 16:16:27
问题 I am trying to compute the derivative of the activation function for softmax. I found this : https://math.stackexchange.com/questions/945871/derivative-of-softmax-loss-function nobody seems to give the proper derivation for how we would get the answers for i=j and i!= j. Could someone please explain this! I am confused with the derivatives when a summation is involved as in the denominator for the softmax activation function. 回答1: The derivative of a sum is the sum of the derivatives, ie: d

LibGDX CatmullRomSpline Derivative Meaning?

前提是你 提交于 2020-01-07 03:04:05
问题 When calling the derivative method on the CatmullRomSpline, what exactly does this value represent? It’s been a while since calculus, but if my memory serves me correctly taking the derivative of the position with respect to time gives you the velocity at that point in time. But with CatmullRomSpline the “time” value is a percentage, so is the resulting derivative in pixels/percent? I printed out the derivative values (vector length) along my path and the values go as high as “989.6049”,

Determining Android Cancel/Back Swipe (Swipe Left To Right) with jQuery

霸气de小男生 提交于 2020-01-03 05:07:44
问题 On the Android, without using a framework like Sencha or JQTouch or JQMobile, but using jQuery (regular jQuery), I want to detect a Cancel/Back Swipe (swiping left to right). I have something accomplished so far, but I'm trying to determine the math formula to implement in jQuery such that I capture a left to right swipe event, and not another kind of gesture. What do you suggest? I imagine I need some kind of acceptable variance. I'm assuming there's some sort of calculus formula that could

Finding the optimal 3D box sizes for a group of 3D rectangular items

梦想与她 提交于 2020-01-01 05:48:26
问题 When I say box I am talking about shipping boxes. I have a number of random sized, small items that I need to pack into as few boxes as possible. I need to know what box sizes are optimal. All items are rectangular prisms. It's easy to exclude a box size for an item which is too large to fit. I know the box sizes (they are the available box sizes which I have in-stock) Items can be positioned horizontally or vertically, not diagonal. As many boxes as required can be used. The goal is to use

Trapezoid and Simpson rule in Python?

随声附和 提交于 2019-12-25 17:45:09
问题 I have to write the trapezoid and simpson rule in python for the function e^((-x)^2) . Here's what I got so far. The answer it gives out is 8218.7167913 but the answer according to my teacher is something like 1.77251356.... . Where did I go wrong? from numpy import * def f(x): return e**((-x)**2) def trapezoid(f, a, b, n): deltax = float(b - a)/(n) h = float(b - a) / n s = 0.0 s += f(a)/2.0 for i in range(1, n): s += f(a + i*h) s += f(b)/2.0 return s * h print trapezoid(f, -3, 3, 6) 回答1:

How to integrate the product of two functions

大兔子大兔子 提交于 2019-12-24 20:54:43
问题 Suppose I am seeking to integrate the following function from 0 to 10: How would I accomplish this in R ? Functions # Functional form fn <- function(t) -100*(t)^2 + 20000 # First derivative w.r.t. t fn_dt <- function(t) -200*t # Density funciton phi phi <- approxfun(density(rnorm(35, 15, 7))) # Delta t delta <- 5 回答1: How about the following: First off, we choose a fixed seed for reproducibility. # Density funciton phi set.seed(2017); phi <- approxfun(density(rnorm(35, 15, 7))) We define the

Pytorch most efficient Jacobian/Hessian calculation

天涯浪子 提交于 2019-12-23 19:43:21
问题 I am looking for the most efficient way to get the Jacobian of a function through Pytorch and have so far come up with the following solutions: def func(X): return torch.stack(( X.pow(2).sum(1), X.pow(3).sum(1), X.pow(4).sum(1) ),1) X = Variable(torch.ones(1,int(1e5))*2.00094, requires_grad=True).cuda() # Solution 1: t = time() Y = func(X) J = torch.zeros(3, int(1e5)) for i in range(3): J[i] = grad(Y[0][i], X, create_graph=True, retain_graph=True, allow_unused=True)[0] print(time()-t) Output:

calculating the Gradient and the Hessian in R

烈酒焚心 提交于 2019-12-21 02:50:06
问题 As you know, the Gradient of a function is the following vector: and the Hessian is the following matrix: Now, I wonder, is there any way to calculate these in R for a user defined function at a given point? First, I've found a package named numDeriv, which seems to have the necessary functions grad and hessian but now I can't get the correct results... Thus, here's my workflow: Let's say that we are given the function f(x,y) = x^2 * x^3, and we need to calculate the Gradient and the Hessian