{"action":"created","issue":{"url":"https://api.github.com/repos/tensorflow/tensorflow/issues/4722","repository_url":"https://api.github.com/repos/tensorflow/tensorflow","labels_url":"https://api.github.com/repos/tensorflow/tensorflow/issues/4722/labels{/name}","comments_url":"https://api.github.com/repos/tensorflow/tensorflow/issues/4722/comments","events_url":"https://api.github.com/repos/tensorflow/tensorflow/issues/4722/events","html_url":"https://github.com/tensorflow/tensorflow/issues/4722","id":180548412,"number":4722,"title":"einsum not fully implemented, tensorflow cannot even perform tensor product??","user":{"login":"xuancong84","id":10172392,"avatar_url":"https://avatars.githubusercontent.com/u/10172392?v=3","gravatar_id":"","url":"https://api.github.com/users/xuancong84","html_url":"https://github.com/xuancong84","followers_url":"https://api.github.com/users/xuancong84/followers","following_url":"https://api.github.com/users/xuancong84/following{/other_user}","gists_url":"https://api.github.com/users/xuancong84/gists{/gist_id}","starred_url":"https://api.github.com/users/xuancong84/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xuancong84/subscriptions","organizations_url":"https://api.github.com/users/xuancong84/orgs","repos_url":"https://api.github.com/users/xuancong84/repos","events_url":"https://api.github.com/users/xuancong84/events{/privacy}","received_events_url":"https://api.github.com/users/xuancong84/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":6,"created_at":"2016-10-03T01:21:59Z","updated_at":"2016-10-15T03:06:29Z","closed_at":null,"body":"I am glad to see the newly added einsum function. The documentation claims that its usage is the same as numpy. However, it can do almost nothing as compared to numpy. For example, it only supports subscripts in the form of '*->*'. Unfortunately, even matrix transpose does not work, i.e., 'ij->ji'. \r\nNumpy works:\r\n```\r\n>>> A\r\narray([[ 0.3828997 , -0.39114848, -0.09727838, -0.20430113],\r\n       [ 0.48020577, -0.47122706,  0.42830791,  0.25665744],\r\n       [-0.30885863,  0.21669025,  0.31648793,  0.22417514],\r\n       [ 0.32505724,  0.30478035,  0.48655034,  0.20040547]])\r\n>>> einsum('ij->ji',A)\r\narray([[ 0.3828997 ,  0.48020577, -0.30885863,  0.32505724],\r\n       [-0.39114848, -0.47122706,  0.21669025,  0.30478035],\r\n       [-0.09727838,  0.42830791,  0.31648793,  0.48655034],\r\n       [-0.20430113,  0.25665744,  0.22417514,  0.20040547]])\r\n```\r\n\r\nTensorflow does not work:\r\n```\r\npseudo-code:\r\nM_ = tf.Variable(tf.random_normal([4,4]))\r\nN_ = tf.einsum('ij->ji',M_)              \r\nprint [M_, N_]\r\n\r\noutput:\r\n[array([[ 0.80474716, -1.38590837, -0.3379252 , -1.24965811],\r\n       [ 2.57852983,  0.05492432,  0.23039417, -0.74263287],\r\n       [-2.42627382,  1.70774114,  1.19503212,  0.43006262],\r\n       [-1.04652011, -0.32753903, -1.26430523,  0.8810069 ]], dtype=float32), \r\narray([[ 0.80474716, -1.38590837, -0.3379252 , -1.24965811],\r\n       [ 2.57852983,  0.05492432,  0.23039417, -0.74263287],\r\n       [-2.42627382,  1.70774114,  1.19503212,  0.43006262],\r\n       [-1.04652011, -0.32753903, -1.26430523,  0.8810069 ]], dtype=float32)]\r\n```\r\n\r\nI want to multiply a matrix with every frame vector in every batch. Or similar operations which can be done by a simple tensor product. It seems that I still have to duplicate the matrix so many times and perform a batch_matmul, which is very inconvenient and slow and memory consuming.\r\n\r\nI suggest tensorflow to implement either the tensordot or einsum function which can perform tensor product.\r\n\r\nIt is quite a shame that tensorflow cannot even perform basic tensor product so far :("},"comment":{"url":"https://api.github.com/repos/tensorflow/tensorflow/issues/comments/253958864","html_url":"https://github.com/tensorflow/tensorflow/issues/4722#issuecomment-253958864","issue_url":"https://api.github.com/repos/tensorflow/tensorflow/issues/4722","id":253958864,"user":{"login":"jart","id":49262,"avatar_url":"https://avatars.githubusercontent.com/u/49262?v=3","gravatar_id":"","url":"https://api.github.com/users/jart","html_url":"https://github.com/jart","followers_url":"https://api.github.com/users/jart/followers","following_url":"https://api.github.com/users/jart/following{/other_user}","gists_url":"https://api.github.com/users/jart/gists{/gist_id}","starred_url":"https://api.github.com/users/jart/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jart/subscriptions","organizations_url":"https://api.github.com/users/jart/orgs","repos_url":"https://api.github.com/users/jart/repos","events_url":"https://api.github.com/users/jart/events{/privacy}","received_events_url":"https://api.github.com/users/jart/received_events","type":"User","site_admin":false},"created_at":"2016-10-15T03:06:29Z","updated_at":"2016-10-15T03:06:29Z","body":"Strong opinions aside, I don't think the OP is being unreasonable. If TensorFlow is offering an op that's \"Like numpy.einsum\" then it should ideally be roughly equivalent in terms of behavior. I just left a comment in PR #4837 suggesting that this function might be more appropriate for the contrib package."}}
{"actor":{"display_login":"jart"}}