Skip to content

Commit

Permalink
[Fix] Fix optimizer 'ValueError' when using PReLU activation (open-mm…
Browse files Browse the repository at this point in the history
…lab#2444)

* fix optimizer ValueError when using PReLU activation.

* fix lint error
  • Loading branch information
KeiChiTse authored and akozlov-outrider committed May 8, 2023
1 parent 1d49f07 commit 4cc63ca
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions mmcv/cnn/bricks/transformer.py
Original file line number Diff line number Diff line change
Expand Up @@ -588,24 +588,21 @@ def __init__(self,
ffn_drop=0.,
dropout_layer=None,
add_identity=True,
init_cfg=None,
**kwargs):
init_cfg=None):
super().__init__(init_cfg)
assert num_fcs >= 2, 'num_fcs should be no less ' \
f'than 2. got {num_fcs}.'
self.embed_dims = embed_dims
self.feedforward_channels = feedforward_channels
self.num_fcs = num_fcs
self.act_cfg = act_cfg
self.activate = build_activation_layer(act_cfg)

layers = []
in_channels = embed_dims
for _ in range(num_fcs - 1):
layers.append(
Sequential(
Linear(in_channels, feedforward_channels), self.activate,
nn.Dropout(ffn_drop)))
Linear(in_channels, feedforward_channels),
build_activation_layer(act_cfg), nn.Dropout(ffn_drop)))
in_channels = feedforward_channels
layers.append(Linear(feedforward_channels, embed_dims))
layers.append(nn.Dropout(ffn_drop))
Expand Down

0 comments on commit 4cc63ca

Please sign in to comment.