Contents
官方的pretrained models
https://github.com/tensorflow/models/tree/master/research/slim#pre-trained-models
一个输入的pipeline
https://blog.csdn.net/u014061630/article/details/80728694
变量名不同时加载ckpt
https://www.cnblogs.com/zyly/p/9146787.html
创建超参数
1 2 3 4 |
import tensorflow as tf hparams = tf.contrib.training.HParams() hparams.path = 'model' |
限制GPU的使用
1 2 3 4 5 6 7 8 9 |
# 通过 allow_soft_placement 参数自动将无法放在 GPU 上的操作放回 CPU gpuConfig = tf.ConfigProto(allow_soft_placement=True) # 限制一个进程使用 60% 的显存 gpuConfig.gpu_options.per_process_gpu_memory_fraction = 0.6 # 运行时需要多少再给多少 gpuConfig.gpu_options.allow_growth = True |
打印所有可训练变量
1 2 3 4 5 6 7 8 9 |
variable_names = [v.name for v in tf.trainable_variables()] values = sess.run(variable_names) for k, v in zip(variable_names, values): print(k) print(" shape: ", v.shape) #print all collections print(tf.get_default_graph().get_all_collection_keys()) |
参数数量
1 2 |
parameter_count = tf.reduce_sum([tf.reduce_prod(tf.shape(v)) for v in tf.trainable_variables()]) |
sess.run的类型
1 2 3 4 5 6 7 8 9 10 11 |
# 运行的时候是什么类型返回就是什么类型 # 列表 a, b = sess.run([x, y]) # 字典 d = {'a': x, 'b': y} result = sess.run(d) result['a'] result['d'] |
图像resize方法
1 2 |
tf.image.resize_images(img, [height, width], method=tf.image.ResizeMethod.*) |
ema
https://blog.csdn.net/huqinweI987/article/details/88241776
control_depencies
https://blog.csdn.net/m0_37041325/article/details/76943364