Skip to content

Instantly share code, notes, and snippets.

@kentsommer
Created February 3, 2017 08:23
Show Gist options
  • Save kentsommer/e872f65926f1a607b94c2b464a63d0d3 to your computer and use it in GitHub Desktop.
Save kentsommer/e872f65926f1a607b94c2b464a63d0d3 to your computer and use it in GitHub Desktop.
row_shuffle Dense Weights
magic_number_1 = size_of_last_conv_layer
magic_number_2 = number_of_rows_in_dense / magic_number_1
def shuffle_rows(original_w):
converted_w = np.zeros(original_w.shape)
count = 0
for index, row in enumerate(original_w):
if (index % magic_number_1) == 0 and index != 0:
count += 1
new_index = ((index % magic_number_1) * magic_number_2) + count
print("index from " + str(index) + " -> " + str(new_index))
converted_w[new_index] = row
initial = 1
return converted_w
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment