Answers.Body: <p>First, there is no way you could recover the exact loss. At best you could recover the loss up to a constant factor, because the gradient is only giving information on the slope on the loss and not the actual loss values.</p>
  <p>If we make assumptions like a standard model architecture, and we have access to the model architecture in addition to the weight values, then it <em>might</em> be possible to recover the loss up to a constant factor. Assuming the (scalar) loss depends only on the output layer, and assuming the weights are updated with vanilla SGD, first we have an eqn like
  <span class="math-container">\begin{align*} 
  \frac{1}{\alpha}(W_{t+1} - W_t) = \dfrac{\partial f}{\partial x_n}\Big(\dfrac{\partial x_n}{\partial W_t} + \dfrac{\partial x_n}{\partial x_{n-1}}\dfrac{\partial x_{n-1}}{\partial W_t} + \ldots \Big)
  \end{align*}</span>
  where <span class="math-container">$\alpha$</span> is the learning rate, <span class="math-container">$f$</span> is the loss function, <span class="math-container">$x_i$</span> are the units of the <span class="math-container">$i$</span>-th layer (<span class="math-container">$x_n$</span> is output, <span class="math-container">$x_0$</span> is input). the LHS is what you know the gradient was and the RHS is the definition of the gradient (based on backprop). In the RHS, the unknowns are the partial derivatives <span class="math-container">$\frac{\partial f}{\partial x_n}$</span>, which has as many unknowns as dimension of the output layer. This is an over-determined system, because there are only <span class="math-container">$\text{dim}(x_n)$</span> unknowns and <span class="math-container">$\dim(W)$</span> equations. Normally this would then have no solution, but in this case, we know there actually are some loss partial derivatives <span class="math-container">$\partial f / \partial x_n$</span> which should satisfy this.</p>
  <p>But this doesn't give you the actual function f. You just get the partial derivatives at <span class="math-container">$x_n$</span>. Then if you wanted to try to recover <span class="math-container">$f$</span> (again, only up to a constant factor), you would need a way to actually evaluate various different <span class="math-container">$x_n$</span>. Then you can &quot;recover&quot; <span class="math-container">$f$</span> (up to a constant factor) by integrating <span class="math-container">$\partial f / \partial x_n$</span> over all possible values of <span class="math-container">$x_n$</span>.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-12-13T18:14:52.597Z
Answers.LastActivityDate: 2022-12-13T18:14:52.597Z
Answers.UserDisplayName: Taw
Body: <p>Assume the gradient updates (both <span class="math-container">$W_t$</span> and <span class="math-container">$W_{t+1}$</span>) and learning rate are known while data <span class="math-container">$X$</span> is unknown, is it possible to deduce the loss <span class="math-container">$L$</span> used in backprop algorithm that gave rise to the gradient update <span class="math-container">$W_{t+1} - W_{t}$</span>? If not, is it possible to verify if a given loss is the one we are looking for (in other words is the loss that gave rise to a known gradient update unique, assume we know the model architecture)?</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2022-12-14T02:06:43.193Z
Comments.Text: This depends on your definition of Loss $L$, $L$ such as MSE is easily calculable according to its formula after each forward pass and its error terms for each output unit are then used to backprop.
Comments.UserDisplayName: cinch
Tags: <backpropagation>
Title: Is it possible to reverse engineer out the loss based on weights update when data is unknown?
UserDisplayName: Sam
ThreadText: # Is it possible to reverse engineer out the loss based on weights update when data is unknown?
  
  (Asked by: username_0 on 2022-12-13)
  
  Assume the gradient updates (both $W\_t$ and $W\_{t+1}$) and learning rate are known while data $X$ is unknown, is it possible to deduce the loss $L$ used in backprop algorithm that gave rise to the gradient update $W\_{t+1} - W\_{t}$? If not, is it possible to verify if a given loss is the one we are looking for (in other words is the loss that gave rise to a known gradient update unique, assume we know the model architecture)?
  
  **Tags:** backpropagation
  > **Comments:**
  > **username_1**: This depends on your definition of Loss $L$, $L$ such as MSE is easily calculable according to its formula after each forward pass and its error terms for each output unit are then used to backprop.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_2 on 2022-12-13. Score: 1 | Accepted answer
  
  First, there is no way you could recover the exact loss. At best you could recover the loss up to a constant factor, because the gradient is only giving information on the slope on the loss and not the actual loss values.
  
  If we make assumptions like a standard model architecture, and we have access to the model architecture in addition to the weight values, then it *might* be possible to recover the loss up to a constant factor. Assuming the (scalar) loss depends only on the output layer, and assuming the weights are updated with vanilla SGD, first we have an eqn like
  \begin{align\*}
  \frac{1}{\alpha}(W\_{t+1} - W\_t) = \dfrac{\partial f}{\partial x\_n}\Big(\dfrac{\partial x\_n}{\partial W\_t} + \dfrac{\partial x\_n}{\partial x\_{n-1}}\dfrac{\partial x\_{n-1}}{\partial W\_t} + \ldots \Big)
  \end{align\*}
  where $\alpha$ is the learning rate, $f$ is the loss function, $x\_i$ are the units of the $i$-th layer ($x\_n$ is output, $x\_0$ is input). the LHS is what you know the gradient was and the RHS is the definition of the gradient (based on backprop). In the RHS, the unknowns are the partial derivatives $\frac{\partial f}{\partial x\_n}$, which has as many unknowns as dimension of the output layer. This is an over-determined system, because there are only $\text{dim}(x\_n)$ unknowns and $\dim(W)$ equations. Normally this would then have no solution, but in this case, we know there actually are some loss partial derivatives $\partial f / \partial x\_n$ which should satisfy this.
  
  But this doesn't give you the actual function f. You just get the partial derivatives at $x\_n$. Then if you wanted to try to recover $f$ (again, only up to a constant factor), you would need a way to actually evaluate various different $x\_n$. Then you can "recover" $f$ (up to a constant factor) by integrating $\partial f / \partial x\_n$ over all possible values of $x\_n$.
  
  
  ---
  
  