Removing less than one batch of data in tensorflow


I don’t need to talk much nonsense, just go to the code!

#-*- coding:utf-8 -*-
import tensorflow as tf
import numpy as np
value1 = tf.placeholder(dtype=tf.float32)
value2 = tf.placeholder(dtype=tf.float32)
value3 = value1 + value2
#Defined dataset has parameters, only parameterized iterators can be used
dataset =
#Defining parametric iterators
dataset = dataset.shuffle(100)
Dataset = dataset. Apply (TF. Contrib. Data. Batch and drop retain (3)) (3 data per batch, less than 3 data discarded)
iterator = dataset.make_initializable_iterator()
next_element = iterator.get_next()
with tf.Session() as sess:
  #Iterators need to be initialized with parameters
  for i in range(2):
    while True:
        value =
        result =,feed_dict={value1:value,value2:value})
      except tf.errors.OutOfRangeError:
        print("End of epoch %d" % i)

The above implementation of removing less than one batch of data in tensorflow is all the content shared by Xiaobian. I hope it can give you a reference, and I hope you can support developer more.