yhtang / FunFact

Tensor decomposition with arbitrary expressions: inner, outer, elementwise operators; nonlinear transformations; and more.
Other
57 stars 4 forks source link

[BUG] Duplicate enumeration of factor tensors #210

Closed yhtang closed 2 years ago

yhtang commented 2 years ago

Describe the bug If a tensor shows up more than once in a tensor expression, then it will also show up as many times in Factorization.factors. This may lead to incorrect behavior during SGD should the same tensor gets updates multiple times during one step.

To Reproduce

import funfact as ff
a = ff.tensor('a', 4)
fac = ff.Factorization.from_tsrex(a * a)
print(fac.factors)

leads to

<'data' fields of tensors a, a>

Expected behavior A tensor should only appear once in .factors regardless of how many times it is used in a tensor expression.