1.
tf.train.latest_checkpoint('./model_data/')
这一句最终返回的是一个字符串,比如
'./model_data/model-99991'
这个方法本身还会做相应的检查,比如checkpoint中最新的模型model_checkpoint_path中的名字在all_model_checkpoint_paths并没有,而是人为修改后的,那么就会提示:
ERROR:tensorflow:Couldn't match files for checkpoint ./model_data/model-99991
只有同时修改4处以后,才会成功执行,分别是model_checkpoint_path、all_model_checkpoint_paths、data-00000-of-00001和index的名字。只有meta的名字不要修改。但是事实上,再执行这一条语句之前,
tf.train.import_meta_graph('model_data/model-99991.meta')
已经被执行了。
2.
tf.trainable_variables () 指的是需要训练的变量
tf.global_variables()指的所有变量
例如:bn层的mean和var在训练变量中就是没有,而只会出现在所有变量中。
3.
from tensorflow.examples.tutorials.mnist import input_data
mnist = input_data.read_data_sets("dataset/", one_hot=True)
-mnist
-train:num_examples、next_batch(4)
-validation
-test
4.caffe和tf中bn的比较
在caffe中训练时为:
layer {
name: "BatchNorm_layer2_1"
type: "BatchNorm"
bottom: "Convolution2_1"
top: "Convolution2_1"
}
在保存的caffemodel中,一共有3个参数,shape分别是64,64,1。
在tf