From what I understand, the proposition of virtual batch norm is to use the statistics of a held-out batch for different input batch x.
I’m porting this tensorflow code:

  
      github.com
  
  
    santi-pdp/segan/blob/master/bnorm.py 36
import tensorflow as tf


class VBN(object):
    """
    Virtual Batch Normalization
    (modified from https://github.com/openai/improved-gan/ definition)
    """

    def __init__(self, x, name, epsilon=1e-5):
        """
        x is the reference batch
        """
        assert isinstance(epsilon, float)

        shape = x.get_shape().as_list()
        assert len(shape) == 3, shape
        with tf.variable_scope(name) as scope:
            assert name.startswith("d_") or name.startswith("g_")
            self.epsilon = epsilon


  This file has been truncated. show original