title: FailedPreconditionError: GetNext() failed because the iterator has not been initialized
body: <p>I am new to tensorflow and trying to create a simple MLP. My model is running fine but is not giving the desired performance. I tried to create summaries but am now getting this error:</p>
  
  <blockquote>
    <p>FailedPreconditionError: GetNext() failed because the iterator has not been initialized. Ensure that you have run the initializer operation for this iterator before getting the next element.</p>
  </blockquote>
  
  <p><strong>My code:</strong></p>
  
  <pre><code>def fc_layer(input, channels_in,channels_out, name = "fc"):
  with tf.name_scope(name):
      W = tf.Variable(tf.zeros([channels_in, channels_out]), name="weights")
      clip_op = tf.assign(W, tf.clip_by_norm(W, 1, axes = None))
      b = tf.Variable(tf.zeros([channels_out]), name="biases")
      act = tf.matmul(input, W) + b
      tf.summary.histogram("weights", W)
      tf.summary.histogram("biases", b)
      tf.summary.histogram("activations", act)
      return act
  
  
  # Setup placeholders, and reshape the data
  y = tf.placeholder(tf.float32, shape=[None,128], name = 'y')
  x = tf.placeholder(tf.float32, shape=[None,256], name = 'x')
  dataset = tf.data.Dataset.from_tensor_slices((y, x)).batch(batch_size).repeat()
  iter = dataset.make_initializable_iterator()
  input_features, output_features = iter.get_next()
  
  fc_1 = tf.nn.relu(fc_layer(input_features, 128,512, name = "fc1"))
  fc_2 = tf.nn.relu(fc_layer(fc_1, 512,256, name = "fc1"))
  out_layer = fc_layer(fc_2, 256,256, name = "out")
  
  with tf.name_scope('loss'):
      loss_op = 
  tf.sqrt(tf.reduce_mean(tf.squared_difference(out_layer,output_features)))
      tf.summary.scalar("loss", loss_op)
  with tf.name_scope('train'):
      train_op = 
  tf.train.AdamOptimizer(learning_rate=learning_rate).minimize(loss_op)
  
  #Summary writer
  merged_summary = tf.summary.merge_all()
  writer = tf.summary.FileWriter(r'C:\Users\Jaweria\Documents\Code_logs', 
  graph=tf.get_default_graph())
  with tf.Session() as sess:
      sess.run(tf.global_variables_initializer())
      # initialise iterator with train data
      sess.run(iter.initializer, feed_dict={ y: train_data[0], x: train_data[1], batch_size: Batch_Size})
      print('Training...')
      for i in range(training_epochs):
          tot_loss = 0
          for _ in range(n_batches):
              _, loss_value = sess.run([train_op, loss_op])
              tot_loss += loss_value
              s = sess.run(merged_summary)
              writer.add_summary(s,i*n_batches+ _)
          print("Iter: {}, Loss: {:.4f}".format(i, tot_loss / n_batches))
      # initialise iterator with test data
      sess.run(iter.initializer, feed_dict={ y: test_data[0], x: test_data[1], 
      batch_size: test_data[0].shape[0]})
      print('Test Loss: {:4f}'.format(sess.run(loss_op)))
  </code></pre>