feature_sharing.py 文件源码

python
阅读 70 收藏 0 点赞 0 评论 0

项目:cmcl 作者: chhwang 项目源码 文件源码
def feature_sharing(features):
    """Feature sharing operation.
    Args:
      features: List of hidden features from models.
    """
    nmodel = len(features)
    with tf.variable_scope('feature_sharing'):
        shape = features[0].get_shape()
        output = [0.]*nmodel
        for from_idx in range(nmodel):
            for to_idx in range(nmodel):
                if from_idx == to_idx:
                    # don't drop hidden features within a model.
                    mask = 1.
                else:
                    # randomly drop features to share with another model.
                    mask = tf.floor(0.7 + tf.random_uniform(shape))
                output[to_idx] += mask * features[from_idx]
        return output
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号