啥时候增加一下最近邻插值算子的二阶导算子,paddle

pieyvz9o  于 2023-02-04  发布在  其他
关注(0)|答案(4)|浏览(206)
def g_path_regularize(fake_img, latents, mean_path_length, decay=0.01):
    noise = paddle.randn(fake_img.shape) / math.sqrt(
        fake_img.shape[2] * fake_img.shape[3])
    grad = paddle.grad(outputs=(fake_img * noise).sum(),
                       inputs=latents,
                       create_graph=True)[0]
    path_lengths = paddle.sqrt((grad * grad).sum(2).mean(1))

    path_mean = mean_path_length + decay * (path_lengths.mean() -
                                            mean_path_length)

    path_penalty = ((path_lengths - path_mean) *
                    (path_lengths - path_mean)).mean()

    return path_penalty, path_lengths.detach().mean(), path_mean.detach()

w8ntj3qf

w8ntj3qf1#

您好,我们已经收到了您的问题,会安排技术人员尽快解答您的问题,请耐心等待。请您再次检查是否提供了清晰的问题描述、复现代码、环境&版本、报错信息等。同时,您也可以通过查看 官网API文档常见问题历史IssueAI社区 来寻求解答。祝您生活愉快~

Hi! We've received your issue and please be patient to get responded. We will arrange technicians to answer your questions as soon as possible. Please make sure that you have posted enough message to demo your request. You may also check out the APIFAQGithub Issue and AI community to get the answer.Have a nice day!

pvcm50d1

pvcm50d12#

把代码里的 True 改成 False

create_graph=True)[0]
gc0ot86w

gc0ot86w3#

为了,梯度惩罚实现,而不是仅仅是让这份代码跑

lsmepo6l

lsmepo6l4#

把代码里的 True 改成 False

create_graph=True)[0]

请你可以去看看paddlegan stylegan2 model里面梯度惩罚的实现,而不是仅仅跑通,我解释的清楚了吗

相关问题