【发布时间】:2020-02-06 09:08:33
【问题描述】:
如何更改 Pytorch 预训练网络的激活层? 这是我的代码:
print("All modules")
for child in net.children():
if isinstance(child,nn.ReLU) or isinstance(child,nn.SELU):
print(child)
print('Before changing activation')
for child in net.children():
if isinstance(child,nn.ReLU) or isinstance(child,nn.SELU):
print(child)
child=nn.SELU()
print(child)
print('after changing activation')
for child in net.children():
if isinstance(child,nn.ReLU) or isinstance(child,nn.SELU):
print(child)
这是我的输出:
All modules
ReLU(inplace=True)
Before changing activation
ReLU(inplace=True)
SELU()
after changing activation
ReLU(inplace=True)
【问题讨论】:
-
你应该检查一下这个更通用的解决方案,适用于任何层:discuss.pytorch.org/t/how-to-modify-a-pretrained-model/60509/…
标签: python neural-network deep-learning pytorch activation-function