首页 > 其他 > 详细

Gram矩阵(pytorch)

时间:2021-07-28 14:08:18      阅读:17      评论:0      收藏:0      [点我收藏+]

风格迁移中广泛使用的

def gram_matrix(y):
    """ Returns the gram matrix of y (used to compute style loss) """
    (b, c, h, w) = y.size()
    features = y.view(b, c, w * h)
    features_t = features.transpose(1, 2)   #C和w*h转置
    gram = features.bmm(features_t) / (c * h * w)   #bmm 将features与features_t相乘
    return gram

 

Gram矩阵(pytorch)

原文:https://www.cnblogs.com/zhanjiahui/p/15069514.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!