Derivative of vector w.r.t. scalar












0














I am struggling with backpropagating BatchNormalization. For that, I would like to take the partial derivative of a vector valued function with respect to a scalar. The simplified function looks like this.



$$
overrightarrow{f}(overrightarrow{x}, y) = overrightarrow{x} + (y,y,y) =
begin{bmatrix}
x_{1} + y
\
x_{2} + y
\
x_{3} + y
end{bmatrix}
$$



I can see that
$$frac{partial{f_i}}{partial{y}} = 1$$
And following this post the partial derivative for the vector-valued function should equal



$$frac{partial{overrightarrow{f}}}{partial{y}} = begin{bmatrix}
1
\
1
\
1
end{bmatrix}$$



But from my knowledge of backprop I thought that the derivative should have the same shape as the variable which is obviously not the case because $dim(frac{partial{overrightarrow{f}}}{partial{y}}) neq dim(y)$



But let's say we have a second function $g(overrightarrow{f}) = g(f_{1}(x_{1}, y), cdots)$, then with the multivariable variable chain rule we would obtain:
$$
frac{partial{g}}{partial{y}} = sum_{i=1}^{3}frac{partial{f_{i}}}{partial{y}} = 3
$$



I would like to ask if my intuition is correct.
Thanks in advance.










share|cite|improve this question





























    0














    I am struggling with backpropagating BatchNormalization. For that, I would like to take the partial derivative of a vector valued function with respect to a scalar. The simplified function looks like this.



    $$
    overrightarrow{f}(overrightarrow{x}, y) = overrightarrow{x} + (y,y,y) =
    begin{bmatrix}
    x_{1} + y
    \
    x_{2} + y
    \
    x_{3} + y
    end{bmatrix}
    $$



    I can see that
    $$frac{partial{f_i}}{partial{y}} = 1$$
    And following this post the partial derivative for the vector-valued function should equal



    $$frac{partial{overrightarrow{f}}}{partial{y}} = begin{bmatrix}
    1
    \
    1
    \
    1
    end{bmatrix}$$



    But from my knowledge of backprop I thought that the derivative should have the same shape as the variable which is obviously not the case because $dim(frac{partial{overrightarrow{f}}}{partial{y}}) neq dim(y)$



    But let's say we have a second function $g(overrightarrow{f}) = g(f_{1}(x_{1}, y), cdots)$, then with the multivariable variable chain rule we would obtain:
    $$
    frac{partial{g}}{partial{y}} = sum_{i=1}^{3}frac{partial{f_{i}}}{partial{y}} = 3
    $$



    I would like to ask if my intuition is correct.
    Thanks in advance.










    share|cite|improve this question



























      0












      0








      0







      I am struggling with backpropagating BatchNormalization. For that, I would like to take the partial derivative of a vector valued function with respect to a scalar. The simplified function looks like this.



      $$
      overrightarrow{f}(overrightarrow{x}, y) = overrightarrow{x} + (y,y,y) =
      begin{bmatrix}
      x_{1} + y
      \
      x_{2} + y
      \
      x_{3} + y
      end{bmatrix}
      $$



      I can see that
      $$frac{partial{f_i}}{partial{y}} = 1$$
      And following this post the partial derivative for the vector-valued function should equal



      $$frac{partial{overrightarrow{f}}}{partial{y}} = begin{bmatrix}
      1
      \
      1
      \
      1
      end{bmatrix}$$



      But from my knowledge of backprop I thought that the derivative should have the same shape as the variable which is obviously not the case because $dim(frac{partial{overrightarrow{f}}}{partial{y}}) neq dim(y)$



      But let's say we have a second function $g(overrightarrow{f}) = g(f_{1}(x_{1}, y), cdots)$, then with the multivariable variable chain rule we would obtain:
      $$
      frac{partial{g}}{partial{y}} = sum_{i=1}^{3}frac{partial{f_{i}}}{partial{y}} = 3
      $$



      I would like to ask if my intuition is correct.
      Thanks in advance.










      share|cite|improve this question















      I am struggling with backpropagating BatchNormalization. For that, I would like to take the partial derivative of a vector valued function with respect to a scalar. The simplified function looks like this.



      $$
      overrightarrow{f}(overrightarrow{x}, y) = overrightarrow{x} + (y,y,y) =
      begin{bmatrix}
      x_{1} + y
      \
      x_{2} + y
      \
      x_{3} + y
      end{bmatrix}
      $$



      I can see that
      $$frac{partial{f_i}}{partial{y}} = 1$$
      And following this post the partial derivative for the vector-valued function should equal



      $$frac{partial{overrightarrow{f}}}{partial{y}} = begin{bmatrix}
      1
      \
      1
      \
      1
      end{bmatrix}$$



      But from my knowledge of backprop I thought that the derivative should have the same shape as the variable which is obviously not the case because $dim(frac{partial{overrightarrow{f}}}{partial{y}}) neq dim(y)$



      But let's say we have a second function $g(overrightarrow{f}) = g(f_{1}(x_{1}, y), cdots)$, then with the multivariable variable chain rule we would obtain:
      $$
      frac{partial{g}}{partial{y}} = sum_{i=1}^{3}frac{partial{f_{i}}}{partial{y}} = 3
      $$



      I would like to ask if my intuition is correct.
      Thanks in advance.







      calculus multivariable-calculus






      share|cite|improve this question















      share|cite|improve this question













      share|cite|improve this question




      share|cite|improve this question








      edited Jan 3 at 23:12

























      asked Jan 3 at 22:08









      oezguensi

      133




      133






















          2 Answers
          2






          active

          oldest

          votes


















          0














          Comment: you cannot sum a vector $x(3 times 1)$ and a scalar $y$.






          share|cite|improve this answer





















          • You CAN, it just doesn't mean anything on its own ($textbf{x}+y=textbf{x}+y$). In any case, I think the OP meant $textbf{x}+(y,y,y)$.
            – R. Burton
            Jan 3 at 22:27












          • In this case, define $y=(y_1,y_2,y_3)$, compute the $3 times 3$ matrix of partial derivatives $$ frac{partial f^T}{partial y}(x,y) $$ and evaluate it at $y=(1,1,1)$, which gives the $3 times 3$ identity matrix.
            – Bertrand
            Jan 3 at 22:37












          • Sorry, I meant and element wise addition such as $mathbf{x} + (y,y,y)$
            – oezguensi
            Jan 3 at 23:14



















          0














          I assume you mean
          $$textbf{f}(textbf{x},y)=textbf{x}+(y,y,y)=(x_1+y,x_2+y,x_3+y)$$
          In which case
          $$frac{partialtextbf{f}}{partial y}=left(frac{partial f_1}{partial y},frac{partial f_2}{partial y},frac{partial f_3}{partial y}right)=(1,1,1)$$
          The dimensions of $y$ are not particularly relevant, and in general the dimensions of the variable you take the derivative with respect to does not matter. In general, for any scalar $x$ and vector valued function $textbf{f}$, $dimleft(frac{partial textbf{f}}{partial x}right)=dim(textbf{f})neq dim(x)$.






          share|cite|improve this answer





















          • Sorry, I meant an element wise addition. Thank you for the answer.
            – oezguensi
            Jan 3 at 23:13











          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
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f3061065%2fderivative-of-vector-w-r-t-scalar%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          2 Answers
          2






          active

          oldest

          votes








          2 Answers
          2






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0














          Comment: you cannot sum a vector $x(3 times 1)$ and a scalar $y$.






          share|cite|improve this answer





















          • You CAN, it just doesn't mean anything on its own ($textbf{x}+y=textbf{x}+y$). In any case, I think the OP meant $textbf{x}+(y,y,y)$.
            – R. Burton
            Jan 3 at 22:27












          • In this case, define $y=(y_1,y_2,y_3)$, compute the $3 times 3$ matrix of partial derivatives $$ frac{partial f^T}{partial y}(x,y) $$ and evaluate it at $y=(1,1,1)$, which gives the $3 times 3$ identity matrix.
            – Bertrand
            Jan 3 at 22:37












          • Sorry, I meant and element wise addition such as $mathbf{x} + (y,y,y)$
            – oezguensi
            Jan 3 at 23:14
















          0














          Comment: you cannot sum a vector $x(3 times 1)$ and a scalar $y$.






          share|cite|improve this answer





















          • You CAN, it just doesn't mean anything on its own ($textbf{x}+y=textbf{x}+y$). In any case, I think the OP meant $textbf{x}+(y,y,y)$.
            – R. Burton
            Jan 3 at 22:27












          • In this case, define $y=(y_1,y_2,y_3)$, compute the $3 times 3$ matrix of partial derivatives $$ frac{partial f^T}{partial y}(x,y) $$ and evaluate it at $y=(1,1,1)$, which gives the $3 times 3$ identity matrix.
            – Bertrand
            Jan 3 at 22:37












          • Sorry, I meant and element wise addition such as $mathbf{x} + (y,y,y)$
            – oezguensi
            Jan 3 at 23:14














          0












          0








          0






          Comment: you cannot sum a vector $x(3 times 1)$ and a scalar $y$.






          share|cite|improve this answer












          Comment: you cannot sum a vector $x(3 times 1)$ and a scalar $y$.







          share|cite|improve this answer












          share|cite|improve this answer



          share|cite|improve this answer










          answered Jan 3 at 22:24









          Bertrand

          413




          413












          • You CAN, it just doesn't mean anything on its own ($textbf{x}+y=textbf{x}+y$). In any case, I think the OP meant $textbf{x}+(y,y,y)$.
            – R. Burton
            Jan 3 at 22:27












          • In this case, define $y=(y_1,y_2,y_3)$, compute the $3 times 3$ matrix of partial derivatives $$ frac{partial f^T}{partial y}(x,y) $$ and evaluate it at $y=(1,1,1)$, which gives the $3 times 3$ identity matrix.
            – Bertrand
            Jan 3 at 22:37












          • Sorry, I meant and element wise addition such as $mathbf{x} + (y,y,y)$
            – oezguensi
            Jan 3 at 23:14


















          • You CAN, it just doesn't mean anything on its own ($textbf{x}+y=textbf{x}+y$). In any case, I think the OP meant $textbf{x}+(y,y,y)$.
            – R. Burton
            Jan 3 at 22:27












          • In this case, define $y=(y_1,y_2,y_3)$, compute the $3 times 3$ matrix of partial derivatives $$ frac{partial f^T}{partial y}(x,y) $$ and evaluate it at $y=(1,1,1)$, which gives the $3 times 3$ identity matrix.
            – Bertrand
            Jan 3 at 22:37












          • Sorry, I meant and element wise addition such as $mathbf{x} + (y,y,y)$
            – oezguensi
            Jan 3 at 23:14
















          You CAN, it just doesn't mean anything on its own ($textbf{x}+y=textbf{x}+y$). In any case, I think the OP meant $textbf{x}+(y,y,y)$.
          – R. Burton
          Jan 3 at 22:27






          You CAN, it just doesn't mean anything on its own ($textbf{x}+y=textbf{x}+y$). In any case, I think the OP meant $textbf{x}+(y,y,y)$.
          – R. Burton
          Jan 3 at 22:27














          In this case, define $y=(y_1,y_2,y_3)$, compute the $3 times 3$ matrix of partial derivatives $$ frac{partial f^T}{partial y}(x,y) $$ and evaluate it at $y=(1,1,1)$, which gives the $3 times 3$ identity matrix.
          – Bertrand
          Jan 3 at 22:37






          In this case, define $y=(y_1,y_2,y_3)$, compute the $3 times 3$ matrix of partial derivatives $$ frac{partial f^T}{partial y}(x,y) $$ and evaluate it at $y=(1,1,1)$, which gives the $3 times 3$ identity matrix.
          – Bertrand
          Jan 3 at 22:37














          Sorry, I meant and element wise addition such as $mathbf{x} + (y,y,y)$
          – oezguensi
          Jan 3 at 23:14




          Sorry, I meant and element wise addition such as $mathbf{x} + (y,y,y)$
          – oezguensi
          Jan 3 at 23:14











          0














          I assume you mean
          $$textbf{f}(textbf{x},y)=textbf{x}+(y,y,y)=(x_1+y,x_2+y,x_3+y)$$
          In which case
          $$frac{partialtextbf{f}}{partial y}=left(frac{partial f_1}{partial y},frac{partial f_2}{partial y},frac{partial f_3}{partial y}right)=(1,1,1)$$
          The dimensions of $y$ are not particularly relevant, and in general the dimensions of the variable you take the derivative with respect to does not matter. In general, for any scalar $x$ and vector valued function $textbf{f}$, $dimleft(frac{partial textbf{f}}{partial x}right)=dim(textbf{f})neq dim(x)$.






          share|cite|improve this answer





















          • Sorry, I meant an element wise addition. Thank you for the answer.
            – oezguensi
            Jan 3 at 23:13
















          0














          I assume you mean
          $$textbf{f}(textbf{x},y)=textbf{x}+(y,y,y)=(x_1+y,x_2+y,x_3+y)$$
          In which case
          $$frac{partialtextbf{f}}{partial y}=left(frac{partial f_1}{partial y},frac{partial f_2}{partial y},frac{partial f_3}{partial y}right)=(1,1,1)$$
          The dimensions of $y$ are not particularly relevant, and in general the dimensions of the variable you take the derivative with respect to does not matter. In general, for any scalar $x$ and vector valued function $textbf{f}$, $dimleft(frac{partial textbf{f}}{partial x}right)=dim(textbf{f})neq dim(x)$.






          share|cite|improve this answer





















          • Sorry, I meant an element wise addition. Thank you for the answer.
            – oezguensi
            Jan 3 at 23:13














          0












          0








          0






          I assume you mean
          $$textbf{f}(textbf{x},y)=textbf{x}+(y,y,y)=(x_1+y,x_2+y,x_3+y)$$
          In which case
          $$frac{partialtextbf{f}}{partial y}=left(frac{partial f_1}{partial y},frac{partial f_2}{partial y},frac{partial f_3}{partial y}right)=(1,1,1)$$
          The dimensions of $y$ are not particularly relevant, and in general the dimensions of the variable you take the derivative with respect to does not matter. In general, for any scalar $x$ and vector valued function $textbf{f}$, $dimleft(frac{partial textbf{f}}{partial x}right)=dim(textbf{f})neq dim(x)$.






          share|cite|improve this answer












          I assume you mean
          $$textbf{f}(textbf{x},y)=textbf{x}+(y,y,y)=(x_1+y,x_2+y,x_3+y)$$
          In which case
          $$frac{partialtextbf{f}}{partial y}=left(frac{partial f_1}{partial y},frac{partial f_2}{partial y},frac{partial f_3}{partial y}right)=(1,1,1)$$
          The dimensions of $y$ are not particularly relevant, and in general the dimensions of the variable you take the derivative with respect to does not matter. In general, for any scalar $x$ and vector valued function $textbf{f}$, $dimleft(frac{partial textbf{f}}{partial x}right)=dim(textbf{f})neq dim(x)$.







          share|cite|improve this answer












          share|cite|improve this answer



          share|cite|improve this answer










          answered Jan 3 at 22:40









          R. Burton

          34919




          34919












          • Sorry, I meant an element wise addition. Thank you for the answer.
            – oezguensi
            Jan 3 at 23:13


















          • Sorry, I meant an element wise addition. Thank you for the answer.
            – oezguensi
            Jan 3 at 23:13
















          Sorry, I meant an element wise addition. Thank you for the answer.
          – oezguensi
          Jan 3 at 23:13




          Sorry, I meant an element wise addition. Thank you for the answer.
          – oezguensi
          Jan 3 at 23:13


















          draft saved

          draft discarded




















































          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.





          Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


          Please pay close attention to the following guidance:


          • 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.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f3061065%2fderivative-of-vector-w-r-t-scalar%23new-answer', 'question_page');
          }
          );

          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







          Popular posts from this blog

          An IMO inspired problem

          Management

          Has there ever been an instance of an active nuclear power plant within or near a war zone?