小编RTn*_*our的帖子

torch.optim 为多维张量返回“ValueError:无法优化非叶张量”

我正在尝试使用torch.optim.adam. 它是redner教程系列中的一段代码,在初始设置下运行良好。它尝试通过将所有顶点移动相同的值来优化场景,称为translation。这是原始代码:

vertices = []
for obj in base:
    vertices.append(obj.vertices.clone())

def model(translation):
    for obj, v in zip(base, vertices):
        obj.vertices = v + translation
    # Assemble the 3D scene.
    scene = pyredner.Scene(camera = camera, objects = objects)
    # Render the scene.
    img = pyredner.render_albedo(scene)
    return img

# Initial guess
# Set requires_grad=True since we want to optimize them later

translation = torch.tensor([10.0, -10.0, 10.0], device = pyredner.get_device(), requires_grad=True)

init = model(translation)
# Visualize the initial …
Run Code Online (Sandbox Code Playgroud)

optimization pytorch tensor

1
推荐指数
1
解决办法
3317
查看次数

标签 统计

optimization ×1

pytorch ×1

tensor ×1