xavier、ortho是神经网络中常用的权重初始化方法,在全连接中这两种权重初始化的方法比较好理解,但是在CNN的卷积网络中的具体实现却不好理解了。
在CNN网络中xavier的初始化可以参看:
xavier,kaiming初始化中的fan_in,fan_out在卷积神经网络是什么意思 
也就是说在CNN中avier的初始化的所用的参数取值为:
fan_in指      kernel_height x kernel_width x in_channel     。
fan_out指 kernel_height x kernel_width x out_channel 。
那么在CNN网络中正交初始化是如何实现的呢?
使用TensorFlow查看文档:
tf.orthogonal_initializer

在CNN网络中主要参看:

给出baselines强化学习算法库的orthogonal_initializer实现:
def ortho_init(scale=1.0):
    def _ortho_init(shape, dtype, partition_info=None):
        # lasagne ortho init for tf
        shape = tuple(shape)
        if len(shape) == 2:
            flat_shape = shape
        elif len(shape) == 4:  # assumes NHWC
            flat_shape = (np.prod(shape[:-1]), shape[-1])
        else:
            raise NotImplementedError
        a = np.random.normal(0.0, 1.0, flat_shape)
        u, _, v = np.linalg.svd(a, full_matrices=False)
        q = u if u.shape == flat_shape else v  # pick the one with the correct shape
        q = q.reshape(shape)
        return (scale * q[:shape[0], :shape[1]]).astype(np.float32)
    return _ortho_init适配CNN网络的代码为:
elif len(shape) == 4:  # assumes NHWC
    flat_shape = (np.prod(shape[:-1]), shape[-1])









