Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to force tensorflow tensors to be symmetric?

I have a set of MxM symmetric matrix Variables in a graph whose values I'd like to optimize.

Is there a way to enforce the symmetric condition?

I've thought about adding a term to the loss function to enforce it, but this seems awkward and roundabout. What I'd hoped for is something like tf.matmul(A,B,symmA=True) where only a triangular portion of A would be used and learned. Or maybe something like tf.upperTriangularToFull(A) which would create a dense matrix from a triangular part.

like image 419
Mark Borgerding Avatar asked Apr 18 '16 15:04

Mark Borgerding


1 Answers

What if you do symA = 0.5 * (A + tf.transpose(A))? It is inefficient but at least it's symmetric.

like image 50
Aaron Avatar answered Sep 23 '22 21:09

Aaron