培训期间的Tensorflow Slim调试 [英] Tensorflow Slim debugging during training

查看:84
本文介绍了培训期间的Tensorflow Slim调试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于初始模型,我主要遵循 .假设我想在每个训练循环中打印批处理中使用的图像数据,即我想在每次训练迭代中打印"images"变量的值 在一组不同的标签上微调模型."代码,由于会话实际上是在slim.training.train函数内部创建的,因此该怎么办,因此如果没有sess,我就无法进行sess.run([images])吗?

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 ?

推荐答案

两个先例答案都可以很好地准确显示图像.

Both precedent answers are very good to visualize images precisely.

但是,如果您希望打印任何其他变量值甚至图像的像素强度,则可以在调用例如slim.learning.train之前使用以下代码:

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 :

    variable = tf.get_default_graph().get_tensor_by_name("variable_name")
    train_tensor = tf.Print(train_tensor, [variable], text_to_print_before_value, summarize=number_of_values_to_print_if_array)

第一行按其名称获取变量(例如,您可以通过tensorboard或通过打印slim.get_model_variables()来获取变量.)

The first line gets the variable by its name (you can get it via tensorboard or by printing slim.get_model_variables() for instance).

第二行在评估train_tensor时打印它,并返回train_tensor本身,以便将此打印"节点添加到图形中.

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.

从Mobilenet模型打印变量的示例:

An example printing a variable from a Mobilenet model:

    beta = tf.get_default_graph().get_tensor_by_name("MobilenetV1/Conv2d_12_pointwise/BatchNorm/beta:0")
    train_tensor = tf.Print(train_tensor, [beta], "beta ", summarize=256)

这篇关于培训期间的Tensorflow Slim调试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆