title: ValueError: Shape must be rank 1 but is rank 2 when doing tf.einsum('i,j->ij',u ,j)
body: <p>I have coded this model with tf.keras ,</p>
  <pre class="lang-py prettyprint-override"><code>    import tensorflow as tf
      from tensorflow import einsum
      from tensorflow import keras
      from tensorflow.keras import layers
      from tensorflow.keras.layers import Flatten , Dot
      from tensorflow.keras.layers import Embedding, Multiply, Dense, Input
      from tensorflow.keras import Model
      from tensorflow.keras.layers import concatenate
      from tensorflow.keras.models import load_model
      num_items = 1250
      num_users = 1453
      emb_size = 32
      input_userID = Input(shape=[1], name='user_ID')
      input_itemID = Input(shape=[1], name='item_ID')
      
      user_emb_GMF = Embedding(num_users, emb_size, name='user_emb_GMF')(input_userID)
      item_emb_GMF = Embedding(num_items, emb_size, name='item_emb_GMF')(input_itemID)
      
      flat_u_GMF = Flatten()(user_emb_GMF)
      flat_i_GMF = Flatten()(item_emb_GMF)
      interraction_map = einsum('i,j-&gt;ij',flat_u_GMF ,flat_i_GMF)  # output[i,j] = u[i]*v[j] 
      layer = Dense(16, activation='relu', name='hidden_layer' )(interraction_map)
      out = Dense(1,activation='sigmoid',name='output')(layer)
      oncf_model = Model([input_userID, input_itemID], out)
      
      tf.keras.utils.plot_model(oncf_model, show_shapes=True)
  </code></pre>
  <p>and basically i want to get the outer product of user_emb_GMF and item_emb_GMF(which is a matrix), and i get the error :</p>
  <pre class="lang-py prettyprint-override"><code>InvalidArgumentError                      Traceback (most recent call last)
  /usr/local/lib/python3.6/dist-packages/tensorflow/python/framework/ops.py in _create_c_op(graph, node_def, inputs, control_inputs, op_def)
     1811   try:
  -&gt; 1812     c_op = pywrap_tf_session.TF_FinishOperation(op_desc)
     1813   except errors.InvalidArgumentError as e:
  
  InvalidArgumentError: Shape must be rank 1 but is rank 2
       for 0th input and equation: i,j-&gt;ij for '{{node Einsum_2}} = Einsum[N=2, T=DT_FLOAT, equation=&quot;i,j-&gt;ij&quot;](flatten_10/Reshape, flatten_11/Reshape)' with input shapes: [?,32], [?,32].
  
  During handling of the above exception, another exception occurred:
  
  ValueError                                Traceback (most recent call last)
  9 frames
  /usr/local/lib/python3.6/dist-packages/tensorflow/python/framework/ops.py in _create_c_op(graph, node_def, inputs, control_inputs, op_def)
     1813   except errors.InvalidArgumentError as e:
     1814     # Convert to ValueError for backwards compatibility.
  -&gt; 1815     raise ValueError(str(e))
     1816 
     1817   return c_op
  
  ValueError: Shape must be rank 1 but is rank 2
       for 0th input and equation: i,j-&gt;ij for '{{node Einsum_2}} = Einsum[N=2, T=DT_FLOAT, equation=&quot;i,j-&gt;ij&quot;](flatten_10/Reshape, flatten_11/Reshape)' with input shapes: [?,32], [?,32].
  </code></pre>
  <p>and i wonder how i can solve the problem</p>