首页 > 解决方案 > 在这种情况下,Pytorch 如何处理反向传播?

问题描述

class ExNet(nn.Module):
    def __init__(self):
        super(ExNet,self).__init__()
        self.fc1 = nn.Linear(1024,500)
        self.fc2 = nn.Linear(500,100)
        self.fc3 = nn.Linear(100,10)


    def forward(self,x,mask1, mask2):
        x = F.relu(self.fc1(x)) 
        x = x * mask
        x = F.relu(self.fc2(x))
        x = x * mask2
        x = F.softmax(self.fc3(x),dim=1)
        return x

我有一些我想应用于我的网络的自定义蒙版(取决于图层)。根据上面的代码,Pytorch 是否考虑了反向传播过程中的掩码特征?我的意思是我的反向传播过程中的梯度会使用这些自定义掩码相乘吗?

标签: pythondeep-learningneural-networkpytorch

解决方案


推荐阅读