Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Write in files during training #1496

Closed
martinjammes opened this issue Nov 25, 2020 · 2 comments
Closed

Write in files during training #1496

martinjammes opened this issue Nov 25, 2020 · 2 comments

Comments

@martinjammes
Copy link

Hello,

I am using Tensorpack for FasterRCNN training and I want to know if it is possible to use the tf.io.write_file function (which returns a tf.Operation object) during training.

If I add these lines in generalized_rcnn.py, a file is written when building the graph but not during the training:

with tf.device('/cpu:0'), tf.Session(config=tf.ConfigProto(
        allow_soft_placement=True, log_device_placement=True), graph=tf.get_default_graph()).as_default():
        tf.io.write_file(file_path, text).run()

It seems that the tf.io.write_file function needs to be used with CPU and under a session, and removing allow_soft_placement=True, log_device_placement=True in the session config induce Colocation errors.

My question is: is it possible to make so that the tf.io.write_file function is run for each new image during training?

I would like to use it to store in a file the total cost associated to each image during training.

@ppwwyyxx
Copy link
Collaborator

is it possible to make so that the tf.io.write_file function is run for each new image during training?

Yes. You need to create the operation and make it a dependency of the training op. Session shall never be created when building the graph. You seem to have a misunderstanding of the concept of graph/session and how tensorflow runs things.

I would like to use it to store in a file the total cost associated to each image during training.

Using https://tensorpack.readthedocs.io/modules/callbacks.html#tensorpack.callbacks.DumpTensors or write a callback following DumpTensors is a much easier way to do that

@martinjammes
Copy link
Author

Thanks a lot, DumpTensors callback was exactly what I need to do this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants