[ 仅 API 调用方式不一致 ]torch.nn.Module.children

torch.nn.Module.children

torch.nn.Module.children()

paddle.nn.Layer.children

paddle.nn.Layer.children()

两者功能一致,但调用方式不一致,具体如下:

转写示例

# PyTorch 写法
model = torch.nn.Sequential(net1, net2)
for layer in model.children():
    print(layer)

# Paddle 写法
model = paddle.nn.Sequential(net1, net2)
for layer in model.children():
    print(layer)