pytorch-Detach的作用
detach()的官方说明如下:
假设有模型A和模型B,我们需要将A的输出作为B的输入,但训练时我们只训练模型B. 那么可以这样做:
input_B = output_A.detach()
它可以使两个计算图的梯度传递断开,从而实现我们所需的功能。
!!!清晰明了!! pytorch的函数 .detach()
pytorch-查看网络参数
Pytorch(六)(模型参数的遍历)——net.parameters() & net.named_parameters() & net.state_dict()