title: Tensor-Flow error: Failed to convert object of type <class 'dict'> to Tensor
body: <p>I'm trying to build and train an AutoEncoder using the following code. The error of cannot convert dict to tensor shows up when I train the model. I think it has something to do with my model but I cannot locate the error. Can anyone help me with this? Thank you.</p>
  
  <pre><code>X = tf.placeholder("float", [None, num_input])
  
  weights = {
      'encoder_h1': tf.Variable(tf.random_normal([num_input, num_hidden_1])),
      'encoder_h2': tf.Variable(tf.random_normal([num_hidden_1, num_hidden_2])),
      'decoder_h1': tf.Variable(tf.random_normal([num_hidden_2, num_hidden_1])),
      'decoder_h2': tf.Variable(tf.random_normal([num_hidden_1, num_input]))}
  
  biases = {
      'encoder_b1': tf.Variable(tf.random_normal([num_hidden_1])),
      'encoder_b2': tf.Variable(tf.random_normal([num_hidden_My model is2])),
      'decoder_b1': tf.Variable(tf.random_normal([num_hidden_1])),
      'decoder_b2': tf.Variable(tf.random_normal([num_input])),}
  
  # Building the encoder
  def encoder(x):
      # Encoder Hidden layer with sigmoid activation #1
      layer_1 = tf.nn.relu(tf.add(tf.matmul(x, weights['encoder_h1']), biases['encoder_b1']))
      # Encoder Hidden layer with sigmoid activation #2
      layer_2 = tf.nn.relu(tf.add(tf.matmul(layer_1, weights['encoder_h2']),biases['encoder_b2']))
      return layer_2
  
  # Building the decoder
  def decoder(x):
      # Decoder Hidden layer with sigmoid activation #1
      layer_1 = tf.nn.relu(tf.add(tf.matmul(x, weights['decoder_h1']), biases['decoder_b1']))
      # Decoder Hidden layer with sigmoid activation #2
      layer_2 = tf.nn.relu(tf.add(tf.matmul(layer_1, weights['decoder_h2']), biases['decoder_b2']))
      return layer_2
  
  # Construct model
  encoder_op = encoder(X)
  decoder_op = decoder(encoder_op)
  
  # Prediction
  y_pred = decoder_op
  # Targets (Labels) are the input data.
  y_true = X
  
  # Define loss and optimizer, minimize the squared error
  loss = tf.reduce_mean(tf.pow(y_true - y_pred, 2))
  optimizer = tf.train.RMSPropOptimizer(learning_rate).minimize(loss)
  
  
  # Initialize the variables (i.e. assign their default value)
  init = tf.global_variables_initializer()
  saver = tf.train.Saver()
  
  # Start Training
  # Start a new TF session
  with tf.Session() as sess:
      writer = tf.summary.FileWriter('./graph', sess.graph)
      # Run the initializer
      sess.run(init)
      saver.save(sess,'./mark2',global_step = 1)
      # Training
      for i in range(0, num_steps):
          # Prepare Data
          fname = "md_0_2_new."+str(i)
          train_batch = np.reshape(minibatch(fname)[:,:,0],[10,num_input],order="f")
          print(np.shape(train_batch))
          for j in range(0,10):
              _, l = sess.run([optimizer, loss], feed_dict={X:np.reshape(train_batch[j],[-1,num_input])})
  
          tf.summary.scalar('loss', l)
          tf.summary.scalar('weights',weights)
          if i % display_step == 0:
              print('Step %i: Minibatch Loss: %f' % (i, l))
  </code></pre>
  
  <p>Error Message:</p>
  
  <pre><code>TypeError: Failed to convert object of type &lt;class 'dict'&gt; to Tensor. Contents: {'encoder_h1': &lt;tf.Variable 'Variable:0' shape=(33876, 256) dtype=float32_ref&gt;, 'encoder_h2': &lt;tf.Variable 'Variable_1:0' shape=(256, 128) dtype=float32_ref&gt;, 'decoder_h1': &lt;tf.Variable 'Variable_2:0' shape=(128, 256) dtype=float32_ref&gt;, 'decoder_h2': &lt;tf.Variable 'Variable_3:0' shape=(256, 33876) dtype=float32_ref&gt;}. Consider casting elements to a supported type.
  </code></pre>