def fix_variables(self, sess, pretrained_model):
print('Fix MobileNet V1 layers..')
with tf.variable_scope('Fix_MobileNet_V1') as scope:
with tf.device("/cpu:0"):
# fix RGB to BGR, and match the scale by (255.0 / 2.0)
Conv2d_0_rgb = tf.get_variable("Conv2d_0_rgb",
[3, 3, 3, max(int(32 * self._depth_multiplier), 8)],
trainable=False)
restorer_fc = tf.train.Saver({self._scope + "/Conv2d_0/weights": Conv2d_0_rgb})
restorer_fc.restore(sess, pretrained_model)
sess.run(tf.assign(self._variables_to_fix[self._scope + "/Conv2d_0/weights:0"],
tf.reverse(Conv2d_0_rgb / (255.0 / 2.0), [2])))
评论列表
文章目录