Skip to content

Commit

Permalink
Remove constant multiplication factor from activation hessian computa…
Browse files Browse the repository at this point in the history
…tion
  • Loading branch information
Ofir Gordon authored and Ofir Gordon committed Nov 28, 2023
1 parent d15d9fc commit 846fdb4
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def compute(self) -> List[float]:
# Compute the final approximation for each output index
num_node_outputs = len(interest_point_scores[0])
for output_idx in range(num_node_outputs):
final_approx_per_output.append(2 * tf.reduce_mean([x[output_idx] for x in interest_point_scores]) / output.shape[-1])
final_approx_per_output.append(tf.reduce_mean([x[output_idx] for x in interest_point_scores]))

# final_approx_per_output is a list of all approximations (one per output), thus we average them to
# get the final score of a node.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@ def compute(self) -> List[float]:
break

trace_hv.append(hessian_trace_approx)
ipts_hessian_trace_approx.append(2 * torch.mean(torch.stack(trace_hv)) / output.shape[
-1]) # Get averaged Hessian trace approximation

ipts_hessian_trace_approx.append(torch.mean(torch.stack(trace_hv))) # Get averaged Hessian trace approximation

# If a node has multiple outputs, it means that multiple approximations were computed
# (one per output since granularity is per-tensor). In this case we average the approximations.
Expand Down

0 comments on commit 846fdb4

Please sign in to comment.