Details
-
Sub-task
-
Status: Closed
-
Major
-
Resolution: Done
-
None
-
None
Description
There are some example scripts which use unnecessary aggregations for convenience of a consistent specification - hence, we should automatically eliminate these unnecessary aggregates, via a simple static rewrite. For example, in below script, we should remove the unnecessary rowSums, but the same applies to min-min, max-max, sum_sq-sum.
# nn lib - cross_entropy_loss::forward (returns only loss) N = nrow(y) eps = 1e-10 # numerical stability to avoid log(0) losses = rowSums(-y * log(pred+eps)) loss = sum(losses) / N