'Take a snapshot of the network after unnormalizing the learned
bounding-box regression weights. This enables easy use at test-time.'

def snapshot(self, sess, iter):

    net = self.net
    if (cfg.TRAIN.BBOX_REG and net.layers.has_key('bbox_pred')):
        with tf.variable_scope('bbox_pred', reuse=True):
            weights = tf.get_variable('weights')
            biases = tf.get_variable('biases')
        orig_0 = weights.eval()
        orig_1 = biases.eval()
        weights_shape = weights.get_shape().as_list()
        sess.run(net.bbox_weights_assign, feed_dict={net.bbox_weights: (orig_0 * np.tile(self.bbox_stds, (weights_shape[0], 1)))})
        sess.run(net.bbox_bias_assign, feed_dict={net.bbox_biases: ((orig_1 * self.bbox_stds) + self.bbox_means)})
    if (not os.path.exists(self.output_dir)):
        os.makedirs(self.output_dir)
    infix = (('_' + cfg.TRAIN.SNAPSHOT_INFIX) if (cfg.TRAIN.SNAPSHOT_INFIX != '') else '')
    filename = (((cfg.TRAIN.SNAPSHOT_PREFIX + infix) + '_iter_{:d}'.format((iter + 1))) + '.ckpt')
    filename = os.path.join(self.output_dir, filename)
    self.saver.save(sess, filename)
    print 'Wrote    snapshot    to:    {:s}'.format(filename)
    if (cfg.TRAIN.BBOX_REG and net.layers.has_key('bbox_pred')):
        with tf.variable_scope('bbox_pred', reuse=True):
            sess.run(net.bbox_weights_assign, feed_dict={net.bbox_weights: orig_0})
            sess.run(net.bbox_bias_assign, feed_dict={net.bbox_biases: orig_1})
