Is there a version of the chain rule that applies to hessian matrices?
$begingroup$
Suppose I have a scalar $J(n)$ and two vectors, $mathbf{w}(n)$ and $mathbf{x}(n)$. Now, suppose that $J(n)$ is a fairly straightforward function of $mathbf{w}(n)$, and $mathbf{w}(n)$ is actually a vector function of $mathbf{x}(n)$ (and a complicated one, for that matter, although $frac{partial mathbf{w}(n)}{partial mathbf{x}(n)}$ is relatively easy to calculate). In order to obtain the gradient of $J(n)$ with respect to $mathbf{x}(n)$, I used
$$ frac{partial J(n)}{partial mathbf{x}(n)} = frac{partial mathbf{w}(n)}{partial mathbf{x}(n)} frac{partial J(n)}{partial mathbf{w}(n)}.$$
Now, I'd like to calculate the Hessian of $J(n)$ with respect to $mathbf{x}(n)$. The thing is, it seems to me it would be a lot easier to calculate $frac{partial^2 J(n)}{partial mathbf{w}^2(n)}$ first and then use the chain rule to obtain $frac{partial^2 J(n)}{partial mathbf{x}^2(n)}$ from the previous result. The problem is that I'm having some difficulty with it. I know that, in single variable calculus, if we have $y = f(u)$ and $u = g(x)$, then
$$frac{d^2y}{dx^2} = frac{d^2y}{du^2}bigg(frac{du}{dx}bigg)^2 + frac{dy}{du} bigg( frac{d^2u}{dx^2} bigg),$$
but how does that apply to matrix calculus? I mean, $frac{partial^2 mathbf{w}(n)}{partial mathbf{x}^2(n)}$ is a tensor, right? How do I deal with this situation? Is it even posible to do what I am thinking?
multivariable-calculus matrix-calculus chain-rule
$endgroup$
add a comment |
$begingroup$
Suppose I have a scalar $J(n)$ and two vectors, $mathbf{w}(n)$ and $mathbf{x}(n)$. Now, suppose that $J(n)$ is a fairly straightforward function of $mathbf{w}(n)$, and $mathbf{w}(n)$ is actually a vector function of $mathbf{x}(n)$ (and a complicated one, for that matter, although $frac{partial mathbf{w}(n)}{partial mathbf{x}(n)}$ is relatively easy to calculate). In order to obtain the gradient of $J(n)$ with respect to $mathbf{x}(n)$, I used
$$ frac{partial J(n)}{partial mathbf{x}(n)} = frac{partial mathbf{w}(n)}{partial mathbf{x}(n)} frac{partial J(n)}{partial mathbf{w}(n)}.$$
Now, I'd like to calculate the Hessian of $J(n)$ with respect to $mathbf{x}(n)$. The thing is, it seems to me it would be a lot easier to calculate $frac{partial^2 J(n)}{partial mathbf{w}^2(n)}$ first and then use the chain rule to obtain $frac{partial^2 J(n)}{partial mathbf{x}^2(n)}$ from the previous result. The problem is that I'm having some difficulty with it. I know that, in single variable calculus, if we have $y = f(u)$ and $u = g(x)$, then
$$frac{d^2y}{dx^2} = frac{d^2y}{du^2}bigg(frac{du}{dx}bigg)^2 + frac{dy}{du} bigg( frac{d^2u}{dx^2} bigg),$$
but how does that apply to matrix calculus? I mean, $frac{partial^2 mathbf{w}(n)}{partial mathbf{x}^2(n)}$ is a tensor, right? How do I deal with this situation? Is it even posible to do what I am thinking?
multivariable-calculus matrix-calculus chain-rule
$endgroup$
$begingroup$
It's an interesting question, and I suspect your approach using single variable calculus is the best to try to work out a matrix formulation in the multivariable case. Perhaps the case of two variables will show if there is a tractable expression to be found.
$endgroup$
– hardmath
Dec 5 '18 at 15:32
$begingroup$
Given that it is a tensor, you just have to contract over the correct pairs of indeces
$endgroup$
– Federico
Dec 5 '18 at 15:33
$begingroup$
And how exactly do I do that? I'm new to tensors and tensor calculus, so if you could recommend a good reference on the subject, I would appreciate it quite a lot.
$endgroup$
– D. Tiglea
Dec 5 '18 at 16:55
add a comment |
$begingroup$
Suppose I have a scalar $J(n)$ and two vectors, $mathbf{w}(n)$ and $mathbf{x}(n)$. Now, suppose that $J(n)$ is a fairly straightforward function of $mathbf{w}(n)$, and $mathbf{w}(n)$ is actually a vector function of $mathbf{x}(n)$ (and a complicated one, for that matter, although $frac{partial mathbf{w}(n)}{partial mathbf{x}(n)}$ is relatively easy to calculate). In order to obtain the gradient of $J(n)$ with respect to $mathbf{x}(n)$, I used
$$ frac{partial J(n)}{partial mathbf{x}(n)} = frac{partial mathbf{w}(n)}{partial mathbf{x}(n)} frac{partial J(n)}{partial mathbf{w}(n)}.$$
Now, I'd like to calculate the Hessian of $J(n)$ with respect to $mathbf{x}(n)$. The thing is, it seems to me it would be a lot easier to calculate $frac{partial^2 J(n)}{partial mathbf{w}^2(n)}$ first and then use the chain rule to obtain $frac{partial^2 J(n)}{partial mathbf{x}^2(n)}$ from the previous result. The problem is that I'm having some difficulty with it. I know that, in single variable calculus, if we have $y = f(u)$ and $u = g(x)$, then
$$frac{d^2y}{dx^2} = frac{d^2y}{du^2}bigg(frac{du}{dx}bigg)^2 + frac{dy}{du} bigg( frac{d^2u}{dx^2} bigg),$$
but how does that apply to matrix calculus? I mean, $frac{partial^2 mathbf{w}(n)}{partial mathbf{x}^2(n)}$ is a tensor, right? How do I deal with this situation? Is it even posible to do what I am thinking?
multivariable-calculus matrix-calculus chain-rule
$endgroup$
Suppose I have a scalar $J(n)$ and two vectors, $mathbf{w}(n)$ and $mathbf{x}(n)$. Now, suppose that $J(n)$ is a fairly straightforward function of $mathbf{w}(n)$, and $mathbf{w}(n)$ is actually a vector function of $mathbf{x}(n)$ (and a complicated one, for that matter, although $frac{partial mathbf{w}(n)}{partial mathbf{x}(n)}$ is relatively easy to calculate). In order to obtain the gradient of $J(n)$ with respect to $mathbf{x}(n)$, I used
$$ frac{partial J(n)}{partial mathbf{x}(n)} = frac{partial mathbf{w}(n)}{partial mathbf{x}(n)} frac{partial J(n)}{partial mathbf{w}(n)}.$$
Now, I'd like to calculate the Hessian of $J(n)$ with respect to $mathbf{x}(n)$. The thing is, it seems to me it would be a lot easier to calculate $frac{partial^2 J(n)}{partial mathbf{w}^2(n)}$ first and then use the chain rule to obtain $frac{partial^2 J(n)}{partial mathbf{x}^2(n)}$ from the previous result. The problem is that I'm having some difficulty with it. I know that, in single variable calculus, if we have $y = f(u)$ and $u = g(x)$, then
$$frac{d^2y}{dx^2} = frac{d^2y}{du^2}bigg(frac{du}{dx}bigg)^2 + frac{dy}{du} bigg( frac{d^2u}{dx^2} bigg),$$
but how does that apply to matrix calculus? I mean, $frac{partial^2 mathbf{w}(n)}{partial mathbf{x}^2(n)}$ is a tensor, right? How do I deal with this situation? Is it even posible to do what I am thinking?
multivariable-calculus matrix-calculus chain-rule
multivariable-calculus matrix-calculus chain-rule
asked Dec 5 '18 at 15:16
D. TigleaD. Tiglea
61
61
$begingroup$
It's an interesting question, and I suspect your approach using single variable calculus is the best to try to work out a matrix formulation in the multivariable case. Perhaps the case of two variables will show if there is a tractable expression to be found.
$endgroup$
– hardmath
Dec 5 '18 at 15:32
$begingroup$
Given that it is a tensor, you just have to contract over the correct pairs of indeces
$endgroup$
– Federico
Dec 5 '18 at 15:33
$begingroup$
And how exactly do I do that? I'm new to tensors and tensor calculus, so if you could recommend a good reference on the subject, I would appreciate it quite a lot.
$endgroup$
– D. Tiglea
Dec 5 '18 at 16:55
add a comment |
$begingroup$
It's an interesting question, and I suspect your approach using single variable calculus is the best to try to work out a matrix formulation in the multivariable case. Perhaps the case of two variables will show if there is a tractable expression to be found.
$endgroup$
– hardmath
Dec 5 '18 at 15:32
$begingroup$
Given that it is a tensor, you just have to contract over the correct pairs of indeces
$endgroup$
– Federico
Dec 5 '18 at 15:33
$begingroup$
And how exactly do I do that? I'm new to tensors and tensor calculus, so if you could recommend a good reference on the subject, I would appreciate it quite a lot.
$endgroup$
– D. Tiglea
Dec 5 '18 at 16:55
$begingroup$
It's an interesting question, and I suspect your approach using single variable calculus is the best to try to work out a matrix formulation in the multivariable case. Perhaps the case of two variables will show if there is a tractable expression to be found.
$endgroup$
– hardmath
Dec 5 '18 at 15:32
$begingroup$
It's an interesting question, and I suspect your approach using single variable calculus is the best to try to work out a matrix formulation in the multivariable case. Perhaps the case of two variables will show if there is a tractable expression to be found.
$endgroup$
– hardmath
Dec 5 '18 at 15:32
$begingroup$
Given that it is a tensor, you just have to contract over the correct pairs of indeces
$endgroup$
– Federico
Dec 5 '18 at 15:33
$begingroup$
Given that it is a tensor, you just have to contract over the correct pairs of indeces
$endgroup$
– Federico
Dec 5 '18 at 15:33
$begingroup$
And how exactly do I do that? I'm new to tensors and tensor calculus, so if you could recommend a good reference on the subject, I would appreciate it quite a lot.
$endgroup$
– D. Tiglea
Dec 5 '18 at 16:55
$begingroup$
And how exactly do I do that? I'm new to tensors and tensor calculus, so if you could recommend a good reference on the subject, I would appreciate it quite a lot.
$endgroup$
– D. Tiglea
Dec 5 '18 at 16:55
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function () {
return StackExchange.using("mathjaxEditing", function () {
StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
});
});
}, "mathjax-editing");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "69"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
noCode: true, onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f3027183%2fis-there-a-version-of-the-chain-rule-that-applies-to-hessian-matrices%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Mathematics Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
Use MathJax to format equations. MathJax reference.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f3027183%2fis-there-a-version-of-the-chain-rule-that-applies-to-hessian-matrices%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
$begingroup$
It's an interesting question, and I suspect your approach using single variable calculus is the best to try to work out a matrix formulation in the multivariable case. Perhaps the case of two variables will show if there is a tractable expression to be found.
$endgroup$
– hardmath
Dec 5 '18 at 15:32
$begingroup$
Given that it is a tensor, you just have to contract over the correct pairs of indeces
$endgroup$
– Federico
Dec 5 '18 at 15:33
$begingroup$
And how exactly do I do that? I'm new to tensors and tensor calculus, so if you could recommend a good reference on the subject, I would appreciate it quite a lot.
$endgroup$
– D. Tiglea
Dec 5 '18 at 16:55