I am largely following this for the inception model. Let's say I want to print the image data being used in the batch on every training loop i.e. I want to print the value of 'images' variable for every training iteration in the 'Fine-tune the model on a different set of labels.' code, how do I do this since the session is actually being created inside the slim.training.train function hence I can't do a sess.run([images]) without sess here ?
相关问题
- how to define constructor for Python's new Nam
- streaming md5sum of contents of a large remote tar
- batch_dot with variable batch size in Keras
- How to get the background from multiple images by
- Evil ctypes hack in python
Both precedent answers are very good to visualize images precisely.
However, if you are interested to print any other variable value or even the pixel intensities of the image, you can use the following code, right before calling slim.learning.train for instance :
The first line gets the variable by its name (you can get it via tensorboard or by printing slim.get_model_variables() for instance).
Second line prints it when train_tensor is evaluated and returns the train_tensor itself so that this Print node is added to the graph.
An example printing a variable from a Mobilenet model:
So you want to visualize the training images? Well, you can add an image summary anywhere you have a handle to them, e.g. under "Train the model on the Flowers dataset.":
With the following script you can see your images:
summaries.add(tf.summary.image('image_tensor,max_images=15,name='images'))
tf.summary.image
is the easiest method because as mentioned session op is created insideslim.learning.train
. Although interactivesession() can be used in the middle of the code, but it may disturb the session created by slim!