foldAdd

foldAdd, function

def autodiff pure foldAdd(a: embedding): number

Returns the sum of all coordinates of the embedding a.

Example

table T = with
  [| as Group |]
  [| "A" |]
  [| "B" |]
  [| "B" |]

T.E = embzero()

show table "Embedding coordinate sums" with
  T.Group
  foldAdd(sum(T.E) default embzero()) as "Coordinate sum"
  group by T.Group

This outputs the following table:

Group Coordinate sum
A -0.4558976
B -0.683846

Remarks

foldAdd is available inside autodiff blocks. It is useful when an embedding value needs to be reduced to a single number.

See also

User Contributed Notes
0 notes + add a note