Restoring a Tensorflow model that uses Iterators

后端 未结 4 2091
遇见更好的自我
遇见更好的自我 2020-12-14 12:21

I have a model that\'s trains my network using an Iterator; following the new Dataset API pipeline model that\'s now recommended by Google.

I read tfrecord files, fe

4条回答
  •  盖世英雄少女心
    2020-12-14 13:18

    I couldn't solve the problem related to initializing the iterator, but since I pre-process my dataset using map method, and I apply transformations defined by Python operations wrapped with py_func, which cannot be serialized for storing\restoring, I'll have to initialize my dataset when I want to restore it anyway.

    So, the problem that remains is how to feed data to my graph when I restore it. I placed a tf.identity node between the iterator output and my network input. Upon restoring, I feed my data to the identity node. A better solution that I discovered later is using placeholder_with_default(), as described in this answer.

提交回复
热议问题