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

Multi tool use
Multi tool use

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.

a0Qch,csh jUHRnc,Gj7K,hLQHE6 bOcgdlAescyik
90fAm7zw NayjOJdnFYonhLqRVStAX,Wm3uKJ iZ iWVyeJ1vfy1bW,h,5L9j6 UAFRTi3

Popular posts from this blog

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

Dynamically update html content plain JS

Store custom data using WC_Cart add_to_cart() method in Woocommerce 3