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 (#870)

Co-authored-by: Ofir Gordon <Ofir.Gordon@altair-semi.com>
  • Loading branch information
ofirgo and Ofir Gordon authored Nov 28, 2023
1 parent c1551a4 commit e76110a
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 @@ -152,7 +152,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 @@ -131,8 +131,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 e76110a

Please sign in to comment.