backstopmedia / tensorflowbook

457 stars 296 forks source link

The memory of the TensorFlow node object could not be reclaimed #28

Closed joylibo closed 6 years ago

joylibo commented 6 years ago

When I try to ran the code Chapter 5 - 05 CNN Implementation.ipynb. I noticed that the memory of the TensorFlow node object could not be reclaimed(For example _image_file = tf.read_file(imagefilename)), and as the for loop in the write_records_file method deepened, the python program took more and more memory, causing me to fail to write all the converted Picture file. What is your solution to this problem?

joylibo commented 6 years ago

I have solved this problem by

for breed, image_filenames in dataset.items():
        g = tf.Graph()
        with g.as_default():
        ...