Skip to content

Commit

Permalink
Refactor: clearer logic
Browse files Browse the repository at this point in the history
Nothing to re-initialize if no filter dropped
  • Loading branch information
siahuat0727 committed May 1, 2019
1 parent 0baa6ba commit b0f46f4
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,12 +179,11 @@ def reinitialize(mask, drop_filters, conv_weights, fc_weights, zero_init):
prev_layer_name = None
prev_num_filters = None
for name, W in conv_weights + fc_weights:
if W.dim() == 4: # conv weights
if W.dim() == 4 and drop_filters[name] is not None: # conv weights
# find null space
size = W.size()
W2d = W.view(size[0], -1).cpu().numpy()
null_space = qr_null(
W2d if drop_filters[name] is None else np.vstack((drop_filters[name], W2d)))
null_space = qr_null(np.vstack((drop_filters[name], W2d)))
null_space = torch.from_numpy(null_space).cuda()
null_space = null_space.transpose(0, 1).view(-1, size[1], size[2], size[3])

Expand Down

0 comments on commit b0f46f4

Please sign in to comment.