How to force tensorflow tensors to be symmetric?

﹥>﹥吖頭↗ 提交于 2019-12-10 03:21:17

问题


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.


回答1:


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



来源:https://stackoverflow.com/questions/36697736/how-to-force-tensorflow-tensors-to-be-symmetric

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!