I am trying to use the batch normal layer from TensorFlow-Slim as follows:
net = ...
net = slim.batch_norm(net, scale = True, is_training = self.isTraining,
updates_collections = None, decay = 0.9)
net = tf.nn.relu(net)
net = ...
I train with:
self.optimizer = slim.learning.create_train_op(self.model.loss,
tf.train.MomentumOptimizer(learning_rate = self.learningRate,
momentum = 0.9, use_nesterov = True)
optimizer = self.sess.run([self.optimizer],
feed_dict={self.model.isTraining:True})
I load saved weights with:
net = model.Model(sess,width,height,channels,weightDecay)
savedWeightsDir = './savedWeights/'
saver = tf.train.Saver(max_to_keep = 5)
checkpointStr = tf.train.latest_checkpoint(savedWeightsDir)
sess.run(tf.global_variables_initializer())
saver.restore(sess, checkpointStr)
global_step = tf.contrib.framework.get_or_create_global_step()
and I conclude:
inf = self.sess.run([self.softmax],
feed_dict = {self.imageBatch:imageBatch,self.isTraining:False})
Of course, I forgot a lot and paraphrased some kind of code, but I think that this is all about the rule of the party. It’s strange if I install isTraining: True, I get much better results. Maybe something with loading in the scales - maybe the values of the batch norm are not saved? Is there something clearly wrong in the code? Thank.
source
share