Will tf.global_variables_initializer() also initialize the iterator for tf.data.Dataset?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP



Will tf.global_variables_initializer() also initialize the iterator for tf.data.Dataset?



I was wondering whether tf.global_variables_initializer() also initializes the iterator for tf.data.Dataset, or I need to initialize the iterator separately as:


tf.global_variables_initializer()


iterator


tf.data.Dataset


iterator




iterator = dataset.make_initializable_iterator()
sess.run(iterator.initializer)



iterator = dataset.make_initializable_iterator()
sess.run(iterator.initializer)




1 Answer
1



You have to initialize the iterator separately.
There is None variable feed to tf.global_variables_initializer()


tf.global_variables_initializer()



official example:


max_value = tf.placeholder(tf.int64, shape=)
dataset = tf.data.Dataset.range(max_value)
iterator = dataset.make_initializable_iterator()
next_element = iterator.get_next()

# Initialize an iterator over a dataset with 10 elements.
sess.run(iterator.initializer, feed_dict=max_value: 10)
for i in range(10):
value = sess.run(next_element)
assert i == value

# Initialize the same iterator over a dataset with 100 elements.
sess.run(iterator.initializer, feed_dict=max_value: 100)
for i in range(100):
value = sess.run(next_element)
assert i == value






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Firebase Auth - with Email and Password - Check user already registered

Dynamically update html content plain JS

How to determine optimal route across keyboard