How to use tf.Dataset design in both training and inferring?
问题 Say, we have input x and label y : iterator = tf.data.Iterator.from_structure((x_type, y_type), (x_shape, y_shape)) tf_x, tf_y = iterator.get_next() Now I use generate function to create dataset: def gen(): for ....: yield (x, y) ds = tf.data.Dataset.from_generator(gen, (x_type, y_type), (x_shape, y_shape)) In my graph, I use tf_x and tf_y to do training, that is fine. But now I want to do referring, where I don't have label y . One workaround I made is to fake a y (like tf.zeros(y_shape)),