import h5py
import numpy as np
np.set_printoptions(threshold=np.nan)

from shutil import copyfile

copyfile("dummy_lutnet.h5", "pretrained_bin.h5") # create pretrained.h5 using datastructure from dummy.h5

bl = h5py.File("baseline_pruned.h5", 'r')
#dummy = h5py.File("dummy.h5", 'r')
pretrained = h5py.File("pretrained_bin.h5", 'r+')

# dense layer 1

bl_w1 = bl["model_weights"]["binary_dense_1"]["binary_dense_1"]["Variable_1:0"]
bl_pruning_mask = bl["model_weights"]["binary_dense_1"]["binary_dense_1"]["pruning_mask:0"]
bl_gamma = bl["model_weights"]["binary_dense_1"]["binary_dense_1"]["Variable:0"]
zero_fill = np.zeros(np.shape(np.array(bl_w1)))
pret_w1 = pretrained["model_weights"]["binary_dense_1"]["binary_dense_1"]["Variable_1:0"]
pret_pruning_mask = pretrained["model_weights"]["binary_dense_1"]["binary_dense_1"]["pruning_mask:0"]
p_gamma = pretrained["model_weights"]["binary_dense_1"]["binary_dense_1"]["Variable:0"]

pret_w1[...] = np.array(bl_w1)
p_gamma[...] = np.array(bl_gamma)
pret_pruning_mask[...] = np.array(bl_pruning_mask)

print(np.sum(np.array(bl_pruning_mask)), np.prod(np.shape(np.array(bl_pruning_mask))))

# dense layer 2

bl_w1 = bl["model_weights"]["binary_dense_2"]["binary_dense_2"]["Variable_1:0"]
bl_rand_map_0 = bl["model_weights"]["binary_dense_2"]["binary_dense_2"]["rand_map_0:0"]
bl_pruning_mask = bl["model_weights"]["binary_dense_2"]["binary_dense_2"]["pruning_mask:0"]
bl_gamma = bl["model_weights"]["binary_dense_2"]["binary_dense_2"]["Variable:0"]
bl_means = bl["model_weights"]["residual_sign_1"]["residual_sign_1"]["means:0"]
pret_rand_map_0 = pretrained["model_weights"]["binary_dense_2"]["binary_dense_2"]["rand_map_0:0"]
pret_rand_map_1 = pretrained["model_weights"]["binary_dense_2"]["binary_dense_2"]["rand_map_1:0"]
pret_rand_map_2 = pretrained["model_weights"]["binary_dense_2"]["binary_dense_2"]["rand_map_2:0"]
pret_pruning_mask = pretrained["model_weights"]["binary_dense_2"]["binary_dense_2"]["pruning_mask:0"]
p_gamma = pretrained["model_weights"]["binary_dense_2"]["binary_dense_2"]["Variable:0"]
pret_means = pretrained["model_weights"]["residual_sign_1"]["residual_sign_1"]["means:0"]

pret_c1 =  pretrained["model_weights"]["binary_dense_2"]["binary_dense_2"]["Variable_1:0"]
pret_c2 =  pretrained["model_weights"]["binary_dense_2"]["binary_dense_2"]["Variable_2:0"]
pret_c3 =  pretrained["model_weights"]["binary_dense_2"]["binary_dense_2"]["Variable_3:0"]
pret_c4 =  pretrained["model_weights"]["binary_dense_2"]["binary_dense_2"]["Variable_4:0"]
pret_c5 =  pretrained["model_weights"]["binary_dense_2"]["binary_dense_2"]["Variable_5:0"]
pret_c6 =  pretrained["model_weights"]["binary_dense_2"]["binary_dense_2"]["Variable_6:0"]
pret_c7 =  pretrained["model_weights"]["binary_dense_2"]["binary_dense_2"]["Variable_7:0"]
pret_c8 =  pretrained["model_weights"]["binary_dense_2"]["binary_dense_2"]["Variable_8:0"]
pret_c9 =  pretrained["model_weights"]["binary_dense_2"]["binary_dense_2"]["Variable_9:0"]
pret_c10=  pretrained["model_weights"]["binary_dense_2"]["binary_dense_2"]["Variable_10:0"]
pret_c11=  pretrained["model_weights"]["binary_dense_2"]["binary_dense_2"]["Variable_11:0"]
pret_c12=  pretrained["model_weights"]["binary_dense_2"]["binary_dense_2"]["Variable_12:0"]
pret_c13=  pretrained["model_weights"]["binary_dense_2"]["binary_dense_2"]["Variable_13:0"]
pret_c14=  pretrained["model_weights"]["binary_dense_2"]["binary_dense_2"]["Variable_14:0"]
pret_c15=  pretrained["model_weights"]["binary_dense_2"]["binary_dense_2"]["Variable_15:0"]
pret_c16=  pretrained["model_weights"]["binary_dense_2"]["binary_dense_2"]["Variable_16:0"]
pret_c17=  pretrained["model_weights"]["binary_dense_2"]["binary_dense_2"]["Variable_17:0"]
pret_c18=  pretrained["model_weights"]["binary_dense_2"]["binary_dense_2"]["Variable_18:0"]
pret_c19=  pretrained["model_weights"]["binary_dense_2"]["binary_dense_2"]["Variable_19:0"]
pret_c20=  pretrained["model_weights"]["binary_dense_2"]["binary_dense_2"]["Variable_20:0"]
pret_c21=  pretrained["model_weights"]["binary_dense_2"]["binary_dense_2"]["Variable_21:0"]
pret_c22=  pretrained["model_weights"]["binary_dense_2"]["binary_dense_2"]["Variable_22:0"]
pret_c23=  pretrained["model_weights"]["binary_dense_2"]["binary_dense_2"]["Variable_23:0"]
pret_c24=  pretrained["model_weights"]["binary_dense_2"]["binary_dense_2"]["Variable_24:0"]
pret_c25=  pretrained["model_weights"]["binary_dense_2"]["binary_dense_2"]["Variable_25:0"]
pret_c26=  pretrained["model_weights"]["binary_dense_2"]["binary_dense_2"]["Variable_26:0"]
pret_c27=  pretrained["model_weights"]["binary_dense_2"]["binary_dense_2"]["Variable_27:0"]
pret_c28=  pretrained["model_weights"]["binary_dense_2"]["binary_dense_2"]["Variable_28:0"]
pret_c29=  pretrained["model_weights"]["binary_dense_2"]["binary_dense_2"]["Variable_29:0"]
pret_c30=  pretrained["model_weights"]["binary_dense_2"]["binary_dense_2"]["Variable_30:0"]
pret_c31=  pretrained["model_weights"]["binary_dense_2"]["binary_dense_2"]["Variable_31:0"]
pret_c32=  pretrained["model_weights"]["binary_dense_2"]["binary_dense_2"]["Variable_32:0"]
pret_w1 =  pretrained["model_weights"]["binary_dense_2"]["binary_dense_2"]["Variable_33:0"]

pret_rand_map_exp_0 = pretrained["model_weights"]["binary_dense_2"]["binary_dense_2"]["rand_map_exp_0:0"]
pret_rand_map_exp_1 = pretrained["model_weights"]["binary_dense_2"]["binary_dense_2"]["rand_map_exp_1:0"]
pret_rand_map_exp_2 = pretrained["model_weights"]["binary_dense_2"]["binary_dense_2"]["rand_map_exp_2:0"]

weight_shape = np.shape(bl_w1)
tile_shape = np.shape(pret_c1)
zero_fill = np.zeros(tile_shape)
one_fill = np.ones(tile_shape)
neg_one_fill = -np.ones(tile_shape)

# randomisation and pruning recovery
bl_w1_unroll = np.array(bl_w1)
bl_w1 = np.array(bl_w1)

rand_map_0 = np.arange(tile_shape[0])
np.random.shuffle(rand_map_0)
rand_map_1 = np.arange(tile_shape[0])
np.random.shuffle(rand_map_1)
rand_map_2 = np.arange(tile_shape[0])
np.random.shuffle(rand_map_2)

pruning_mask = np.array(bl_pruning_mask).astype(bool)
init_mask = np.logical_not(pruning_mask[rand_map_0])
pruning_mask_recover = np.logical_and(pruning_mask, init_mask)[np.argsort(rand_map_0)]
pruning_mask = np.logical_or(pruning_mask, pruning_mask_recover)
init_mask = np.reshape(init_mask, tile_shape)

# expand randomisation map across tiles

rand_map_0_expand = np.tile(rand_map_0,[weight_shape[0]/tile_shape[0]])
rand_map_1_expand = np.tile(rand_map_1,[weight_shape[0]/tile_shape[0]])
rand_map_2_expand = np.tile(rand_map_2,[weight_shape[0]/tile_shape[0]])
for i in range(weight_shape[0]):
        rand_map_0_expand[i] = rand_map_0_expand[i] + (tile_shape[0]*(weight_shape[0]/tile_shape[0]-1)) * (rand_map_0_expand[i]/tile_shape[0]) + tile_shape[0]*(i%weight_shape[0]/tile_shape[0])
        rand_map_1_expand[i] = rand_map_1_expand[i] + (tile_shape[0]*(weight_shape[0]/tile_shape[0]-1)) * (rand_map_1_expand[i]/tile_shape[0]) + tile_shape[0]*(i%weight_shape[0]/tile_shape[0])
        rand_map_2_expand[i] = rand_map_2_expand[i] + (tile_shape[0]*(weight_shape[0]/tile_shape[0]-1)) * (rand_map_2_expand[i]/tile_shape[0]) + tile_shape[0]*(i%weight_shape[0]/tile_shape[0])

bl_w1_rand_0 = bl_w1_unroll[rand_map_0_expand]
bl_w1_rand_0 = np.reshape(bl_w1_rand_0, weight_shape)

w1 = bl_w1

# connect1 only
c1  = one_fill
c2  = neg_one_fill
c3  = one_fill
c4  = neg_one_fill
c5  = one_fill
c6  = neg_one_fill
c7  = one_fill
c8  = neg_one_fill
c9  = one_fill
c10 = neg_one_fill
c11 = one_fill
c12 = neg_one_fill
c13 = one_fill
c14 = neg_one_fill
c15 = one_fill
c16 = neg_one_fill
c17 = neg_one_fill
c18 = one_fill
c19 = neg_one_fill
c20 = one_fill
c21 = neg_one_fill
c22 = one_fill
c23 = neg_one_fill
c24 = one_fill
c25 = neg_one_fill
c26 = one_fill
c27 = neg_one_fill
c28 = one_fill
c29 = neg_one_fill
c30 = one_fill
c31 = neg_one_fill
c32 = one_fill

pret_w1 [...] = w1
pret_c1 [...] = c1
pret_c2 [...] = c2
pret_c3 [...] = c3
pret_c4 [...] = c4
pret_c5 [...] = c5
pret_c6 [...] = c6
pret_c7 [...] = c7
pret_c8 [...] = c8
pret_c9 [...] = c9
pret_c10[...] = c10
pret_c11[...] = c11
pret_c12[...] = c12
pret_c13[...] = c13
pret_c14[...] = c14
pret_c15[...] = c15
pret_c16[...] = c16
pret_c17[...] = c17
pret_c18[...] = c18
pret_c19[...] = c19
pret_c20[...] = c20
pret_c21[...] = c21
pret_c22[...] = c22
pret_c23[...] = c23
pret_c24[...] = c24
pret_c25[...] = c25
pret_c26[...] = c26
pret_c27[...] = c27
pret_c28[...] = c28
pret_c29[...] = c29
pret_c30[...] = c30
pret_c31[...] = c31
pret_c32[...] = c32

pret_rand_map_0[...] = np.reshape(rand_map_0, (-1,1)).astype(float)
pret_rand_map_1[...] = np.reshape(rand_map_1, (-1,1)).astype(float)
pret_rand_map_2[...] = np.reshape(rand_map_2, (-1,1)).astype(float)
p_gamma[...] = np.array(bl_gamma)
pret_means[...] = np.array(bl_means)
pret_pruning_mask[...] = np.array(bl_pruning_mask)

rand_map_0_expand = np.reshape(rand_map_0_expand, [-1,1]).astype(float)
pret_rand_map_exp_0[...] = rand_map_0_expand
rand_map_1_expand = np.reshape(rand_map_1_expand, [-1,1]).astype(float)
pret_rand_map_exp_1[...] = rand_map_1_expand
rand_map_2_expand = np.reshape(rand_map_2_expand, [-1,1]).astype(float)
pret_rand_map_exp_2[...] = rand_map_2_expand

print(np.sum(np.array(bl_pruning_mask)), np.prod(np.shape(np.array(bl_pruning_mask))))

# dense layer 3

bl_w1 = bl["model_weights"]["binary_dense_3"]["binary_dense_3"]["Variable_1:0"]
bl_rand_map_0 = bl["model_weights"]["binary_dense_3"]["binary_dense_3"]["rand_map_0:0"]
bl_pruning_mask = bl["model_weights"]["binary_dense_3"]["binary_dense_3"]["pruning_mask:0"]
bl_gamma = bl["model_weights"]["binary_dense_3"]["binary_dense_3"]["Variable:0"]
bl_means = bl["model_weights"]["residual_sign_2"]["residual_sign_2"]["means:0"]
pret_rand_map_0 = pretrained["model_weights"]["binary_dense_3"]["binary_dense_3"]["rand_map_0:0"]
pret_rand_map_1 = pretrained["model_weights"]["binary_dense_3"]["binary_dense_3"]["rand_map_1:0"]
pret_rand_map_2 = pretrained["model_weights"]["binary_dense_3"]["binary_dense_3"]["rand_map_2:0"]
pret_pruning_mask = pretrained["model_weights"]["binary_dense_3"]["binary_dense_3"]["pruning_mask:0"]
p_gamma = pretrained["model_weights"]["binary_dense_3"]["binary_dense_3"]["Variable:0"]
pret_means = pretrained["model_weights"]["residual_sign_2"]["residual_sign_2"]["means:0"]

pret_c1 =  pretrained["model_weights"]["binary_dense_3"]["binary_dense_3"]["Variable_1:0"]
pret_c2 =  pretrained["model_weights"]["binary_dense_3"]["binary_dense_3"]["Variable_2:0"]
pret_c3 =  pretrained["model_weights"]["binary_dense_3"]["binary_dense_3"]["Variable_3:0"]
pret_c4 =  pretrained["model_weights"]["binary_dense_3"]["binary_dense_3"]["Variable_4:0"]
pret_c5 =  pretrained["model_weights"]["binary_dense_3"]["binary_dense_3"]["Variable_5:0"]
pret_c6 =  pretrained["model_weights"]["binary_dense_3"]["binary_dense_3"]["Variable_6:0"]
pret_c7 =  pretrained["model_weights"]["binary_dense_3"]["binary_dense_3"]["Variable_7:0"]
pret_c8 =  pretrained["model_weights"]["binary_dense_3"]["binary_dense_3"]["Variable_8:0"]
pret_c9 =  pretrained["model_weights"]["binary_dense_3"]["binary_dense_3"]["Variable_9:0"]
pret_c10=  pretrained["model_weights"]["binary_dense_3"]["binary_dense_3"]["Variable_10:0"]
pret_c11=  pretrained["model_weights"]["binary_dense_3"]["binary_dense_3"]["Variable_11:0"]
pret_c12=  pretrained["model_weights"]["binary_dense_3"]["binary_dense_3"]["Variable_12:0"]
pret_c13=  pretrained["model_weights"]["binary_dense_3"]["binary_dense_3"]["Variable_13:0"]
pret_c14=  pretrained["model_weights"]["binary_dense_3"]["binary_dense_3"]["Variable_14:0"]
pret_c15=  pretrained["model_weights"]["binary_dense_3"]["binary_dense_3"]["Variable_15:0"]
pret_c16=  pretrained["model_weights"]["binary_dense_3"]["binary_dense_3"]["Variable_16:0"]
pret_c17=  pretrained["model_weights"]["binary_dense_3"]["binary_dense_3"]["Variable_17:0"]
pret_c18=  pretrained["model_weights"]["binary_dense_3"]["binary_dense_3"]["Variable_18:0"]
pret_c19=  pretrained["model_weights"]["binary_dense_3"]["binary_dense_3"]["Variable_19:0"]
pret_c20=  pretrained["model_weights"]["binary_dense_3"]["binary_dense_3"]["Variable_20:0"]
pret_c21=  pretrained["model_weights"]["binary_dense_3"]["binary_dense_3"]["Variable_21:0"]
pret_c22=  pretrained["model_weights"]["binary_dense_3"]["binary_dense_3"]["Variable_22:0"]
pret_c23=  pretrained["model_weights"]["binary_dense_3"]["binary_dense_3"]["Variable_23:0"]
pret_c24=  pretrained["model_weights"]["binary_dense_3"]["binary_dense_3"]["Variable_24:0"]
pret_c25=  pretrained["model_weights"]["binary_dense_3"]["binary_dense_3"]["Variable_25:0"]
pret_c26=  pretrained["model_weights"]["binary_dense_3"]["binary_dense_3"]["Variable_26:0"]
pret_c27=  pretrained["model_weights"]["binary_dense_3"]["binary_dense_3"]["Variable_27:0"]
pret_c28=  pretrained["model_weights"]["binary_dense_3"]["binary_dense_3"]["Variable_28:0"]
pret_c29=  pretrained["model_weights"]["binary_dense_3"]["binary_dense_3"]["Variable_29:0"]
pret_c30=  pretrained["model_weights"]["binary_dense_3"]["binary_dense_3"]["Variable_30:0"]
pret_c31=  pretrained["model_weights"]["binary_dense_3"]["binary_dense_3"]["Variable_31:0"]
pret_c32=  pretrained["model_weights"]["binary_dense_3"]["binary_dense_3"]["Variable_32:0"]
pret_w1 =  pretrained["model_weights"]["binary_dense_3"]["binary_dense_3"]["Variable_33:0"]

pret_rand_map_exp_0 = pretrained["model_weights"]["binary_dense_3"]["binary_dense_3"]["rand_map_exp_0:0"]
pret_rand_map_exp_1 = pretrained["model_weights"]["binary_dense_3"]["binary_dense_3"]["rand_map_exp_1:0"]
pret_rand_map_exp_2 = pretrained["model_weights"]["binary_dense_3"]["binary_dense_3"]["rand_map_exp_2:0"]

weight_shape = np.shape(bl_w1)
tile_shape = np.shape(pret_c1)
zero_fill = np.zeros(tile_shape)
one_fill = np.ones(tile_shape)
neg_one_fill = -np.ones(tile_shape)

# randomisation and pruning recovery
bl_w1_unroll = np.array(bl_w1)
bl_w1 = np.array(bl_w1)

rand_map_0 = np.arange(tile_shape[0])
np.random.shuffle(rand_map_0)
rand_map_1 = np.arange(tile_shape[0])
np.random.shuffle(rand_map_1)
rand_map_2 = np.arange(tile_shape[0])
np.random.shuffle(rand_map_2)

pruning_mask = np.array(bl_pruning_mask).astype(bool)
init_mask = np.logical_not(pruning_mask[rand_map_0])
pruning_mask_recover = np.logical_and(pruning_mask, init_mask)[np.argsort(rand_map_0)]
pruning_mask = np.logical_or(pruning_mask, pruning_mask_recover)
init_mask = np.reshape(init_mask, tile_shape)

# expand randomisation map across tiles

rand_map_0_expand = np.tile(rand_map_0,[weight_shape[0]/tile_shape[0]])
rand_map_1_expand = np.tile(rand_map_1,[weight_shape[0]/tile_shape[0]])
rand_map_2_expand = np.tile(rand_map_2,[weight_shape[0]/tile_shape[0]])
for i in range(weight_shape[0]):
        rand_map_0_expand[i] = rand_map_0_expand[i] + (tile_shape[0]*(weight_shape[0]/tile_shape[0]-1)) * (rand_map_0_expand[i]/tile_shape[0]) + tile_shape[0]*(i%weight_shape[0]/tile_shape[0])
        rand_map_1_expand[i] = rand_map_1_expand[i] + (tile_shape[0]*(weight_shape[0]/tile_shape[0]-1)) * (rand_map_1_expand[i]/tile_shape[0]) + tile_shape[0]*(i%weight_shape[0]/tile_shape[0])
        rand_map_2_expand[i] = rand_map_2_expand[i] + (tile_shape[0]*(weight_shape[0]/tile_shape[0]-1)) * (rand_map_2_expand[i]/tile_shape[0]) + tile_shape[0]*(i%weight_shape[0]/tile_shape[0])

bl_w1_rand_0 = bl_w1_unroll[rand_map_0_expand]
bl_w1_rand_0 = np.reshape(bl_w1_rand_0, weight_shape)

w1 = bl_w1

# connect1 only
c1  = one_fill
c2  = neg_one_fill
c3  = one_fill
c4  = neg_one_fill
c5  = one_fill
c6  = neg_one_fill
c7  = one_fill
c8  = neg_one_fill
c9  = one_fill
c10 = neg_one_fill
c11 = one_fill
c12 = neg_one_fill
c13 = one_fill
c14 = neg_one_fill
c15 = one_fill
c16 = neg_one_fill
c17 = neg_one_fill
c18 = one_fill
c19 = neg_one_fill
c20 = one_fill
c21 = neg_one_fill
c22 = one_fill
c23 = neg_one_fill
c24 = one_fill
c25 = neg_one_fill
c26 = one_fill
c27 = neg_one_fill
c28 = one_fill
c29 = neg_one_fill
c30 = one_fill
c31 = neg_one_fill
c32 = one_fill

pret_w1 [...] = w1
pret_c1 [...] = c1
pret_c2 [...] = c2
pret_c3 [...] = c3
pret_c4 [...] = c4
pret_c5 [...] = c5
pret_c6 [...] = c6
pret_c7 [...] = c7
pret_c8 [...] = c8
pret_c9 [...] = c9
pret_c10[...] = c10
pret_c11[...] = c11
pret_c12[...] = c12
pret_c13[...] = c13
pret_c14[...] = c14
pret_c15[...] = c15
pret_c16[...] = c16
pret_c17[...] = c17
pret_c18[...] = c18
pret_c19[...] = c19
pret_c20[...] = c20
pret_c21[...] = c21
pret_c22[...] = c22
pret_c23[...] = c23
pret_c24[...] = c24
pret_c25[...] = c25
pret_c26[...] = c26
pret_c27[...] = c27
pret_c28[...] = c28
pret_c29[...] = c29
pret_c30[...] = c30
pret_c31[...] = c31
pret_c32[...] = c32

pret_rand_map_0[...] = np.reshape(rand_map_0, (-1,1)).astype(float)
pret_rand_map_1[...] = np.reshape(rand_map_1, (-1,1)).astype(float)
pret_rand_map_2[...] = np.reshape(rand_map_2, (-1,1)).astype(float)
p_gamma[...] = np.array(bl_gamma)
pret_means[...] = np.array(bl_means)
pret_pruning_mask[...] = np.array(bl_pruning_mask)

rand_map_0_expand = np.reshape(rand_map_0_expand, [-1,1]).astype(float)
pret_rand_map_exp_0[...] = rand_map_0_expand
rand_map_1_expand = np.reshape(rand_map_1_expand, [-1,1]).astype(float)
pret_rand_map_exp_1[...] = rand_map_1_expand
rand_map_2_expand = np.reshape(rand_map_2_expand, [-1,1]).astype(float)
pret_rand_map_exp_2[...] = rand_map_2_expand

print(np.sum(np.array(bl_pruning_mask)), np.prod(np.shape(np.array(bl_pruning_mask))))

# dense layer 4

bl_w1 = bl["model_weights"]["binary_dense_4"]["binary_dense_4"]["Variable_1:0"]
bl_rand_map_0 = bl["model_weights"]["binary_dense_4"]["binary_dense_4"]["rand_map_0:0"]
bl_pruning_mask = bl["model_weights"]["binary_dense_4"]["binary_dense_4"]["pruning_mask:0"]
bl_gamma = bl["model_weights"]["binary_dense_4"]["binary_dense_4"]["Variable:0"]
bl_means = bl["model_weights"]["residual_sign_3"]["residual_sign_3"]["means:0"]
pret_rand_map_0 = pretrained["model_weights"]["binary_dense_4"]["binary_dense_4"]["rand_map_0:0"]
pret_rand_map_1 = pretrained["model_weights"]["binary_dense_4"]["binary_dense_4"]["rand_map_1:0"]
pret_rand_map_2 = pretrained["model_weights"]["binary_dense_4"]["binary_dense_4"]["rand_map_2:0"]
pret_pruning_mask = pretrained["model_weights"]["binary_dense_4"]["binary_dense_4"]["pruning_mask:0"]
p_gamma = pretrained["model_weights"]["binary_dense_4"]["binary_dense_4"]["Variable:0"]
pret_means = pretrained["model_weights"]["residual_sign_3"]["residual_sign_3"]["means:0"]

pret_c1 =  pretrained["model_weights"]["binary_dense_4"]["binary_dense_4"]["Variable_1:0"]
pret_c2 =  pretrained["model_weights"]["binary_dense_4"]["binary_dense_4"]["Variable_2:0"]
pret_c3 =  pretrained["model_weights"]["binary_dense_4"]["binary_dense_4"]["Variable_3:0"]
pret_c4 =  pretrained["model_weights"]["binary_dense_4"]["binary_dense_4"]["Variable_4:0"]
pret_c5 =  pretrained["model_weights"]["binary_dense_4"]["binary_dense_4"]["Variable_5:0"]
pret_c6 =  pretrained["model_weights"]["binary_dense_4"]["binary_dense_4"]["Variable_6:0"]
pret_c7 =  pretrained["model_weights"]["binary_dense_4"]["binary_dense_4"]["Variable_7:0"]
pret_c8 =  pretrained["model_weights"]["binary_dense_4"]["binary_dense_4"]["Variable_8:0"]
pret_c9 =  pretrained["model_weights"]["binary_dense_4"]["binary_dense_4"]["Variable_9:0"]
pret_c10=  pretrained["model_weights"]["binary_dense_4"]["binary_dense_4"]["Variable_10:0"]
pret_c11=  pretrained["model_weights"]["binary_dense_4"]["binary_dense_4"]["Variable_11:0"]
pret_c12=  pretrained["model_weights"]["binary_dense_4"]["binary_dense_4"]["Variable_12:0"]
pret_c13=  pretrained["model_weights"]["binary_dense_4"]["binary_dense_4"]["Variable_13:0"]
pret_c14=  pretrained["model_weights"]["binary_dense_4"]["binary_dense_4"]["Variable_14:0"]
pret_c15=  pretrained["model_weights"]["binary_dense_4"]["binary_dense_4"]["Variable_15:0"]
pret_c16=  pretrained["model_weights"]["binary_dense_4"]["binary_dense_4"]["Variable_16:0"]
pret_c17=  pretrained["model_weights"]["binary_dense_4"]["binary_dense_4"]["Variable_17:0"]
pret_c18=  pretrained["model_weights"]["binary_dense_4"]["binary_dense_4"]["Variable_18:0"]
pret_c19=  pretrained["model_weights"]["binary_dense_4"]["binary_dense_4"]["Variable_19:0"]
pret_c20=  pretrained["model_weights"]["binary_dense_4"]["binary_dense_4"]["Variable_20:0"]
pret_c21=  pretrained["model_weights"]["binary_dense_4"]["binary_dense_4"]["Variable_21:0"]
pret_c22=  pretrained["model_weights"]["binary_dense_4"]["binary_dense_4"]["Variable_22:0"]
pret_c23=  pretrained["model_weights"]["binary_dense_4"]["binary_dense_4"]["Variable_23:0"]
pret_c24=  pretrained["model_weights"]["binary_dense_4"]["binary_dense_4"]["Variable_24:0"]
pret_c25=  pretrained["model_weights"]["binary_dense_4"]["binary_dense_4"]["Variable_25:0"]
pret_c26=  pretrained["model_weights"]["binary_dense_4"]["binary_dense_4"]["Variable_26:0"]
pret_c27=  pretrained["model_weights"]["binary_dense_4"]["binary_dense_4"]["Variable_27:0"]
pret_c28=  pretrained["model_weights"]["binary_dense_4"]["binary_dense_4"]["Variable_28:0"]
pret_c29=  pretrained["model_weights"]["binary_dense_4"]["binary_dense_4"]["Variable_29:0"]
pret_c30=  pretrained["model_weights"]["binary_dense_4"]["binary_dense_4"]["Variable_30:0"]
pret_c31=  pretrained["model_weights"]["binary_dense_4"]["binary_dense_4"]["Variable_31:0"]
pret_c32=  pretrained["model_weights"]["binary_dense_4"]["binary_dense_4"]["Variable_32:0"]
pret_w1 =  pretrained["model_weights"]["binary_dense_4"]["binary_dense_4"]["Variable_33:0"]

pret_rand_map_exp_0 = pretrained["model_weights"]["binary_dense_4"]["binary_dense_4"]["rand_map_exp_0:0"]
pret_rand_map_exp_1 = pretrained["model_weights"]["binary_dense_4"]["binary_dense_4"]["rand_map_exp_1:0"]
pret_rand_map_exp_2 = pretrained["model_weights"]["binary_dense_4"]["binary_dense_4"]["rand_map_exp_2:0"]

weight_shape = np.shape(bl_w1)
tile_shape = np.shape(pret_c1)
zero_fill = np.zeros(tile_shape)
one_fill = np.ones(tile_shape)
neg_one_fill = -np.ones(tile_shape)

# randomisation and pruning recovery
bl_w1_unroll = np.array(bl_w1)
bl_w1 = np.array(bl_w1)

rand_map_0 = np.arange(tile_shape[0])
np.random.shuffle(rand_map_0)
rand_map_1 = np.arange(tile_shape[0])
np.random.shuffle(rand_map_1)
rand_map_2 = np.arange(tile_shape[0])
np.random.shuffle(rand_map_2)

pruning_mask = np.array(bl_pruning_mask).astype(bool)
init_mask = np.logical_not(pruning_mask[rand_map_0])
pruning_mask_recover = np.logical_and(pruning_mask, init_mask)[np.argsort(rand_map_0)]
pruning_mask = np.logical_or(pruning_mask, pruning_mask_recover)
init_mask = np.reshape(init_mask, tile_shape)

# expand randomisation map across tiles

rand_map_0_expand = np.tile(rand_map_0,[weight_shape[0]/tile_shape[0]])
rand_map_1_expand = np.tile(rand_map_1,[weight_shape[0]/tile_shape[0]])
rand_map_2_expand = np.tile(rand_map_2,[weight_shape[0]/tile_shape[0]])
for i in range(weight_shape[0]):
        rand_map_0_expand[i] = rand_map_0_expand[i] + (tile_shape[0]*(weight_shape[0]/tile_shape[0]-1)) * (rand_map_0_expand[i]/tile_shape[0]) + tile_shape[0]*(i%weight_shape[0]/tile_shape[0])
        rand_map_1_expand[i] = rand_map_1_expand[i] + (tile_shape[0]*(weight_shape[0]/tile_shape[0]-1)) * (rand_map_1_expand[i]/tile_shape[0]) + tile_shape[0]*(i%weight_shape[0]/tile_shape[0])
        rand_map_2_expand[i] = rand_map_2_expand[i] + (tile_shape[0]*(weight_shape[0]/tile_shape[0]-1)) * (rand_map_2_expand[i]/tile_shape[0]) + tile_shape[0]*(i%weight_shape[0]/tile_shape[0])

bl_w1_rand_0 = bl_w1_unroll[rand_map_0_expand]
bl_w1_rand_0 = np.reshape(bl_w1_rand_0, weight_shape)

w1 = bl_w1

# connect1 only
c1  = one_fill
c2  = neg_one_fill
c3  = one_fill
c4  = neg_one_fill
c5  = one_fill
c6  = neg_one_fill
c7  = one_fill
c8  = neg_one_fill
c9  = one_fill
c10 = neg_one_fill
c11 = one_fill
c12 = neg_one_fill
c13 = one_fill
c14 = neg_one_fill
c15 = one_fill
c16 = neg_one_fill
c17 = neg_one_fill
c18 = one_fill
c19 = neg_one_fill
c20 = one_fill
c21 = neg_one_fill
c22 = one_fill
c23 = neg_one_fill
c24 = one_fill
c25 = neg_one_fill
c26 = one_fill
c27 = neg_one_fill
c28 = one_fill
c29 = neg_one_fill
c30 = one_fill
c31 = neg_one_fill
c32 = one_fill

pret_w1 [...] = w1
pret_c1 [...] = c1
pret_c2 [...] = c2
pret_c3 [...] = c3
pret_c4 [...] = c4
pret_c5 [...] = c5
pret_c6 [...] = c6
pret_c7 [...] = c7
pret_c8 [...] = c8
pret_c9 [...] = c9
pret_c10[...] = c10
pret_c11[...] = c11
pret_c12[...] = c12
pret_c13[...] = c13
pret_c14[...] = c14
pret_c15[...] = c15
pret_c16[...] = c16
pret_c17[...] = c17
pret_c18[...] = c18
pret_c19[...] = c19
pret_c20[...] = c20
pret_c21[...] = c21
pret_c22[...] = c22
pret_c23[...] = c23
pret_c24[...] = c24
pret_c25[...] = c25
pret_c26[...] = c26
pret_c27[...] = c27
pret_c28[...] = c28
pret_c29[...] = c29
pret_c30[...] = c30
pret_c31[...] = c31
pret_c32[...] = c32

pret_rand_map_0[...] = np.reshape(rand_map_0, (-1,1)).astype(float)
pret_rand_map_1[...] = np.reshape(rand_map_1, (-1,1)).astype(float)
pret_rand_map_2[...] = np.reshape(rand_map_2, (-1,1)).astype(float)
p_gamma[...] = np.array(bl_gamma)
pret_means[...] = np.array(bl_means)
pret_pruning_mask[...] = np.array(bl_pruning_mask)

rand_map_0_expand = np.reshape(rand_map_0_expand, [-1,1]).astype(float)
pret_rand_map_exp_0[...] = rand_map_0_expand
rand_map_1_expand = np.reshape(rand_map_1_expand, [-1,1]).astype(float)
pret_rand_map_exp_1[...] = rand_map_1_expand
rand_map_2_expand = np.reshape(rand_map_2_expand, [-1,1]).astype(float)
pret_rand_map_exp_2[...] = rand_map_2_expand

print(np.sum(np.array(bl_pruning_mask)), np.prod(np.shape(np.array(bl_pruning_mask))))

# dense layer 5

bl_w1 = bl["model_weights"]["binary_dense_5"]["binary_dense_5"]["Variable_1:0"]
bl_rand_map_0 = bl["model_weights"]["binary_dense_5"]["binary_dense_5"]["rand_map_0:0"]
bl_pruning_mask = bl["model_weights"]["binary_dense_5"]["binary_dense_5"]["pruning_mask:0"]
bl_gamma = bl["model_weights"]["binary_dense_5"]["binary_dense_5"]["Variable:0"]
bl_means = bl["model_weights"]["residual_sign_4"]["residual_sign_4"]["means:0"]
pret_rand_map_0 = pretrained["model_weights"]["binary_dense_5"]["binary_dense_5"]["rand_map_0:0"]
pret_rand_map_1 = pretrained["model_weights"]["binary_dense_5"]["binary_dense_5"]["rand_map_1:0"]
pret_rand_map_2 = pretrained["model_weights"]["binary_dense_5"]["binary_dense_5"]["rand_map_2:0"]
pret_pruning_mask = pretrained["model_weights"]["binary_dense_5"]["binary_dense_5"]["pruning_mask:0"]
p_gamma = pretrained["model_weights"]["binary_dense_5"]["binary_dense_5"]["Variable:0"]
pret_means = pretrained["model_weights"]["residual_sign_4"]["residual_sign_4"]["means:0"]

pret_c1 =  pretrained["model_weights"]["binary_dense_5"]["binary_dense_5"]["Variable_1:0"]
pret_c2 =  pretrained["model_weights"]["binary_dense_5"]["binary_dense_5"]["Variable_2:0"]
pret_c3 =  pretrained["model_weights"]["binary_dense_5"]["binary_dense_5"]["Variable_3:0"]
pret_c4 =  pretrained["model_weights"]["binary_dense_5"]["binary_dense_5"]["Variable_4:0"]
pret_c5 =  pretrained["model_weights"]["binary_dense_5"]["binary_dense_5"]["Variable_5:0"]
pret_c6 =  pretrained["model_weights"]["binary_dense_5"]["binary_dense_5"]["Variable_6:0"]
pret_c7 =  pretrained["model_weights"]["binary_dense_5"]["binary_dense_5"]["Variable_7:0"]
pret_c8 =  pretrained["model_weights"]["binary_dense_5"]["binary_dense_5"]["Variable_8:0"]
pret_c9 =  pretrained["model_weights"]["binary_dense_5"]["binary_dense_5"]["Variable_9:0"]
pret_c10=  pretrained["model_weights"]["binary_dense_5"]["binary_dense_5"]["Variable_10:0"]
pret_c11=  pretrained["model_weights"]["binary_dense_5"]["binary_dense_5"]["Variable_11:0"]
pret_c12=  pretrained["model_weights"]["binary_dense_5"]["binary_dense_5"]["Variable_12:0"]
pret_c13=  pretrained["model_weights"]["binary_dense_5"]["binary_dense_5"]["Variable_13:0"]
pret_c14=  pretrained["model_weights"]["binary_dense_5"]["binary_dense_5"]["Variable_14:0"]
pret_c15=  pretrained["model_weights"]["binary_dense_5"]["binary_dense_5"]["Variable_15:0"]
pret_c16=  pretrained["model_weights"]["binary_dense_5"]["binary_dense_5"]["Variable_16:0"]
pret_c17=  pretrained["model_weights"]["binary_dense_5"]["binary_dense_5"]["Variable_17:0"]
pret_c18=  pretrained["model_weights"]["binary_dense_5"]["binary_dense_5"]["Variable_18:0"]
pret_c19=  pretrained["model_weights"]["binary_dense_5"]["binary_dense_5"]["Variable_19:0"]
pret_c20=  pretrained["model_weights"]["binary_dense_5"]["binary_dense_5"]["Variable_20:0"]
pret_c21=  pretrained["model_weights"]["binary_dense_5"]["binary_dense_5"]["Variable_21:0"]
pret_c22=  pretrained["model_weights"]["binary_dense_5"]["binary_dense_5"]["Variable_22:0"]
pret_c23=  pretrained["model_weights"]["binary_dense_5"]["binary_dense_5"]["Variable_23:0"]
pret_c24=  pretrained["model_weights"]["binary_dense_5"]["binary_dense_5"]["Variable_24:0"]
pret_c25=  pretrained["model_weights"]["binary_dense_5"]["binary_dense_5"]["Variable_25:0"]
pret_c26=  pretrained["model_weights"]["binary_dense_5"]["binary_dense_5"]["Variable_26:0"]
pret_c27=  pretrained["model_weights"]["binary_dense_5"]["binary_dense_5"]["Variable_27:0"]
pret_c28=  pretrained["model_weights"]["binary_dense_5"]["binary_dense_5"]["Variable_28:0"]
pret_c29=  pretrained["model_weights"]["binary_dense_5"]["binary_dense_5"]["Variable_29:0"]
pret_c30=  pretrained["model_weights"]["binary_dense_5"]["binary_dense_5"]["Variable_30:0"]
pret_c31=  pretrained["model_weights"]["binary_dense_5"]["binary_dense_5"]["Variable_31:0"]
pret_c32=  pretrained["model_weights"]["binary_dense_5"]["binary_dense_5"]["Variable_32:0"]
pret_w1 =  pretrained["model_weights"]["binary_dense_5"]["binary_dense_5"]["Variable_33:0"]

pret_rand_map_exp_0 = pretrained["model_weights"]["binary_dense_5"]["binary_dense_5"]["rand_map_exp_0:0"]
pret_rand_map_exp_1 = pretrained["model_weights"]["binary_dense_5"]["binary_dense_5"]["rand_map_exp_1:0"]
pret_rand_map_exp_2 = pretrained["model_weights"]["binary_dense_5"]["binary_dense_5"]["rand_map_exp_2:0"]

weight_shape = np.shape(bl_w1)
tile_shape = np.shape(pret_c1)
zero_fill = np.zeros(tile_shape)
one_fill = np.ones(tile_shape)
neg_one_fill = -np.ones(tile_shape)

# randomisation and pruning recovery
bl_w1_unroll = np.array(bl_w1)
bl_w1 = np.array(bl_w1)

rand_map_0 = np.arange(tile_shape[0])
np.random.shuffle(rand_map_0)
rand_map_1 = np.arange(tile_shape[0])
np.random.shuffle(rand_map_1)
rand_map_2 = np.arange(tile_shape[0])
np.random.shuffle(rand_map_2)

pruning_mask = np.array(bl_pruning_mask).astype(bool)
init_mask = np.logical_not(pruning_mask[rand_map_0])
pruning_mask_recover = np.logical_and(pruning_mask, init_mask)[np.argsort(rand_map_0)]
pruning_mask = np.logical_or(pruning_mask, pruning_mask_recover)
init_mask = np.reshape(init_mask, tile_shape)

# expand randomisation map across tiles

rand_map_0_expand = np.tile(rand_map_0,[weight_shape[0]/tile_shape[0]])
rand_map_1_expand = np.tile(rand_map_1,[weight_shape[0]/tile_shape[0]])
rand_map_2_expand = np.tile(rand_map_2,[weight_shape[0]/tile_shape[0]])
for i in range(weight_shape[0]):
        rand_map_0_expand[i] = rand_map_0_expand[i] + (tile_shape[0]*(weight_shape[0]/tile_shape[0]-1)) * (rand_map_0_expand[i]/tile_shape[0]) + tile_shape[0]*(i%weight_shape[0]/tile_shape[0])
        rand_map_1_expand[i] = rand_map_1_expand[i] + (tile_shape[0]*(weight_shape[0]/tile_shape[0]-1)) * (rand_map_1_expand[i]/tile_shape[0]) + tile_shape[0]*(i%weight_shape[0]/tile_shape[0])
        rand_map_2_expand[i] = rand_map_2_expand[i] + (tile_shape[0]*(weight_shape[0]/tile_shape[0]-1)) * (rand_map_2_expand[i]/tile_shape[0]) + tile_shape[0]*(i%weight_shape[0]/tile_shape[0])

bl_w1_rand_0 = bl_w1_unroll[rand_map_0_expand]
bl_w1_rand_0 = np.reshape(bl_w1_rand_0, weight_shape)

w1 = bl_w1

# connect1 only
c1  = one_fill
c2  = neg_one_fill
c3  = one_fill
c4  = neg_one_fill
c5  = one_fill
c6  = neg_one_fill
c7  = one_fill
c8  = neg_one_fill
c9  = one_fill
c10 = neg_one_fill
c11 = one_fill
c12 = neg_one_fill
c13 = one_fill
c14 = neg_one_fill
c15 = one_fill
c16 = neg_one_fill
c17 = neg_one_fill
c18 = one_fill
c19 = neg_one_fill
c20 = one_fill
c21 = neg_one_fill
c22 = one_fill
c23 = neg_one_fill
c24 = one_fill
c25 = neg_one_fill
c26 = one_fill
c27 = neg_one_fill
c28 = one_fill
c29 = neg_one_fill
c30 = one_fill
c31 = neg_one_fill
c32 = one_fill

pret_w1 [...] = w1
pret_c1 [...] = c1
pret_c2 [...] = c2
pret_c3 [...] = c3
pret_c4 [...] = c4
pret_c5 [...] = c5
pret_c6 [...] = c6
pret_c7 [...] = c7
pret_c8 [...] = c8
pret_c9 [...] = c9
pret_c10[...] = c10
pret_c11[...] = c11
pret_c12[...] = c12
pret_c13[...] = c13
pret_c14[...] = c14
pret_c15[...] = c15
pret_c16[...] = c16
pret_c17[...] = c17
pret_c18[...] = c18
pret_c19[...] = c19
pret_c20[...] = c20
pret_c21[...] = c21
pret_c22[...] = c22
pret_c23[...] = c23
pret_c24[...] = c24
pret_c25[...] = c25
pret_c26[...] = c26
pret_c27[...] = c27
pret_c28[...] = c28
pret_c29[...] = c29
pret_c30[...] = c30
pret_c31[...] = c31
pret_c32[...] = c32

pret_rand_map_0[...] = np.reshape(rand_map_0, (-1,1)).astype(float)
pret_rand_map_1[...] = np.reshape(rand_map_1, (-1,1)).astype(float)
pret_rand_map_2[...] = np.reshape(rand_map_2, (-1,1)).astype(float)
p_gamma[...] = np.array(bl_gamma)
pret_means[...] = np.array(bl_means)
pret_pruning_mask[...] = np.array(bl_pruning_mask)

rand_map_0_expand = np.reshape(rand_map_0_expand, [-1,1]).astype(float)
pret_rand_map_exp_0[...] = rand_map_0_expand
rand_map_1_expand = np.reshape(rand_map_1_expand, [-1,1]).astype(float)
pret_rand_map_exp_1[...] = rand_map_1_expand
rand_map_2_expand = np.reshape(rand_map_2_expand, [-1,1]).astype(float)
pret_rand_map_exp_2[...] = rand_map_2_expand

print(np.sum(np.array(bl_pruning_mask)), np.prod(np.shape(np.array(bl_pruning_mask))))


# bn 1

bl_beta = bl["model_weights"]["batch_normalization_1"]["batch_normalization_1"]["beta:0"]
bl_gamma = bl["model_weights"]["batch_normalization_1"]["batch_normalization_1"]["gamma:0"]
bl_moving_mean = bl["model_weights"]["batch_normalization_1"]["batch_normalization_1"]["moving_mean:0"]
bl_moving_variance = bl["model_weights"]["batch_normalization_1"]["batch_normalization_1"]["moving_variance:0"]
p_beta = pretrained["model_weights"]["batch_normalization_1"]["batch_normalization_1"]["beta:0"]
p_gamma = pretrained["model_weights"]["batch_normalization_1"]["batch_normalization_1"]["gamma:0"]
p_moving_mean = pretrained["model_weights"]["batch_normalization_1"]["batch_normalization_1"]["moving_mean:0"]
p_moving_variance = pretrained["model_weights"]["batch_normalization_1"]["batch_normalization_1"]["moving_variance:0"]

p_beta[...] = np.array(bl_beta)
p_gamma[...] = np.array(bl_gamma)
p_moving_mean[...] = np.array(bl_moving_mean)
p_moving_variance[...] = np.array(bl_moving_variance)

# bn 2

bl_beta = bl["model_weights"]["batch_normalization_2"]["batch_normalization_2"]["beta:0"]
bl_gamma = bl["model_weights"]["batch_normalization_2"]["batch_normalization_2"]["gamma:0"]
bl_moving_mean = bl["model_weights"]["batch_normalization_2"]["batch_normalization_2"]["moving_mean:0"]
bl_moving_variance = bl["model_weights"]["batch_normalization_2"]["batch_normalization_2"]["moving_variance:0"]
p_beta = pretrained["model_weights"]["batch_normalization_2"]["batch_normalization_2"]["beta:0"]
p_gamma = pretrained["model_weights"]["batch_normalization_2"]["batch_normalization_2"]["gamma:0"]
p_moving_mean = pretrained["model_weights"]["batch_normalization_2"]["batch_normalization_2"]["moving_mean:0"]
p_moving_variance = pretrained["model_weights"]["batch_normalization_2"]["batch_normalization_2"]["moving_variance:0"]

p_beta[...] = np.array(bl_beta)
p_gamma[...] = np.array(bl_gamma)
p_moving_mean[...] = np.array(bl_moving_mean)
p_moving_variance[...] = np.array(bl_moving_variance)

# bn 3

bl_beta = bl["model_weights"]["batch_normalization_3"]["batch_normalization_3"]["beta:0"]
bl_gamma = bl["model_weights"]["batch_normalization_3"]["batch_normalization_3"]["gamma:0"]
bl_moving_mean = bl["model_weights"]["batch_normalization_3"]["batch_normalization_3"]["moving_mean:0"]
bl_moving_variance = bl["model_weights"]["batch_normalization_3"]["batch_normalization_3"]["moving_variance:0"]
p_beta = pretrained["model_weights"]["batch_normalization_3"]["batch_normalization_3"]["beta:0"]
p_gamma = pretrained["model_weights"]["batch_normalization_3"]["batch_normalization_3"]["gamma:0"]
p_moving_mean = pretrained["model_weights"]["batch_normalization_3"]["batch_normalization_3"]["moving_mean:0"]
p_moving_variance = pretrained["model_weights"]["batch_normalization_3"]["batch_normalization_3"]["moving_variance:0"]

p_beta[...] = np.array(bl_beta)
p_gamma[...] = np.array(bl_gamma)
p_moving_mean[...] = np.array(bl_moving_mean)
p_moving_variance[...] = np.array(bl_moving_variance)

# bn 4

bl_beta = bl["model_weights"]["batch_normalization_4"]["batch_normalization_4"]["beta:0"]
bl_gamma = bl["model_weights"]["batch_normalization_4"]["batch_normalization_4"]["gamma:0"]
bl_moving_mean = bl["model_weights"]["batch_normalization_4"]["batch_normalization_4"]["moving_mean:0"]
bl_moving_variance = bl["model_weights"]["batch_normalization_4"]["batch_normalization_4"]["moving_variance:0"]
p_beta = pretrained["model_weights"]["batch_normalization_4"]["batch_normalization_4"]["beta:0"]
p_gamma = pretrained["model_weights"]["batch_normalization_4"]["batch_normalization_4"]["gamma:0"]
p_moving_mean = pretrained["model_weights"]["batch_normalization_4"]["batch_normalization_4"]["moving_mean:0"]
p_moving_variance = pretrained["model_weights"]["batch_normalization_4"]["batch_normalization_4"]["moving_variance:0"]

p_beta[...] = np.array(bl_beta)
p_gamma[...] = np.array(bl_gamma)
p_moving_mean[...] = np.array(bl_moving_mean)
p_moving_variance[...] = np.array(bl_moving_variance)

# bn 5

bl_beta = bl["model_weights"]["batch_normalization_5"]["batch_normalization_5"]["beta:0"]
bl_gamma = bl["model_weights"]["batch_normalization_5"]["batch_normalization_5"]["gamma:0"]
bl_moving_mean = bl["model_weights"]["batch_normalization_5"]["batch_normalization_5"]["moving_mean:0"]
bl_moving_variance = bl["model_weights"]["batch_normalization_5"]["batch_normalization_5"]["moving_variance:0"]
p_beta = pretrained["model_weights"]["batch_normalization_5"]["batch_normalization_5"]["beta:0"]
p_gamma = pretrained["model_weights"]["batch_normalization_5"]["batch_normalization_5"]["gamma:0"]
p_moving_mean = pretrained["model_weights"]["batch_normalization_5"]["batch_normalization_5"]["moving_mean:0"]
p_moving_variance = pretrained["model_weights"]["batch_normalization_5"]["batch_normalization_5"]["moving_variance:0"]

p_beta[...] = np.array(bl_beta)
p_gamma[...] = np.array(bl_gamma)
p_moving_mean[...] = np.array(bl_moving_mean)
p_moving_variance[...] = np.array(bl_moving_variance)

pretrained.close()

[((31, 68), 'numpy.set_printoptions', 'np.set_printoptions', ([], {'threshold': 'np.nan'}), '(threshold=np.nan)\n', (50, 68), True, 'import numpy as np\n'), ((99, 147), 'shutil.copyfile', 'copyfile', (['"""dummy_lutnet.h5"""', '"""pretrained_bin.h5"""'], {}), "('dummy_lutnet.h5', 'pretrained_bin.h5')\n", (107, 147), False, 'from shutil import copyfile\n'), ((211, 247), 'h5py.File', 'h5py.File', (['"""baseline_pruned.h5"""', '"""r"""'], {}), "('baseline_pruned.h5', 'r')\n", (220, 247), False, 'import h5py\n'), ((297, 333), 'h5py.File', 'h5py.File', (['"""pretrained_bin.h5"""', '"""r+"""'], {}), "('pretrained_bin.h5', 'r+')\n", (306, 333), False, 'import h5py\n'), ((949, 964), 'numpy.array', 'np.array', (['bl_w1'], {}), '(bl_w1)\n', (957, 964), True, 'import numpy as np\n'), ((980, 998), 'numpy.array', 'np.array', (['bl_gamma'], {}), '(bl_gamma)\n', (988, 998), True, 'import numpy as np\n'), ((1024, 1049), 'numpy.array', 'np.array', (['bl_pruning_mask'], {}), '(bl_pruning_mask)\n', (1032, 1049), True, 'import numpy as np\n'), ((5514, 5529), 'numpy.shape', 'np.shape', (['bl_w1'], {}), '(bl_w1)\n', (5522, 5529), True, 'import numpy as np\n'), ((5543, 5560), 'numpy.shape', 'np.shape', (['pret_c1'], {}), '(pret_c1)\n', (5551, 5560), True, 'import numpy as np\n'), ((5573, 5593), 'numpy.zeros', 'np.zeros', (['tile_shape'], {}), '(tile_shape)\n', (5581, 5593), True, 'import numpy as np\n'), ((5605, 5624), 'numpy.ones', 'np.ones', (['tile_shape'], {}), '(tile_shape)\n', (5612, 5624), True, 'import numpy as np\n'), ((5714, 5729), 'numpy.array', 'np.array', (['bl_w1'], {}), '(bl_w1)\n', (5722, 5729), True, 'import numpy as np\n'), ((5738, 5753), 'numpy.array', 'np.array', (['bl_w1'], {}), '(bl_w1)\n', (5746, 5753), True, 'import numpy as np\n'), ((5768, 5792), 'numpy.arange', 'np.arange', (['tile_shape[0]'], {}), '(tile_shape[0])\n', (5777, 5792), True, 'import numpy as np\n'), ((5793, 5822), 'numpy.random.shuffle', 'np.random.shuffle', (['rand_map_0'], {}), '(rand_map_0)\n', (5810, 5822), True, 'import numpy as np\n'), ((5836, 5860), 'numpy.arange', 'np.arange', (['tile_shape[0]'], {}), '(tile_shape[0])\n', (5845, 5860), True, 'import numpy as np\n'), ((5861, 5890), 'numpy.random.shuffle', 'np.random.shuffle', (['rand_map_1'], {}), '(rand_map_1)\n', (5878, 5890), True, 'import numpy as np\n'), ((5904, 5928), 'numpy.arange', 'np.arange', (['tile_shape[0]'], {}), '(tile_shape[0])\n', (5913, 5928), True, 'import numpy as np\n'), ((5929, 5958), 'numpy.random.shuffle', 'np.random.shuffle', (['rand_map_2'], {}), '(rand_map_2)\n', (5946, 5958), True, 'import numpy as np\n'), ((6026, 6066), 'numpy.logical_not', 'np.logical_not', (['pruning_mask[rand_map_0]'], {}), '(pruning_mask[rand_map_0])\n', (6040, 6066), True, 'import numpy as np\n'), ((6169, 6218), 'numpy.logical_or', 'np.logical_or', (['pruning_mask', 'pruning_mask_recover'], {}), '(pruning_mask, pruning_mask_recover)\n', (6182, 6218), True, 'import numpy as np\n'), ((6231, 6264), 'numpy.reshape', 'np.reshape', (['init_mask', 'tile_shape'], {}), '(init_mask, tile_shape)\n', (6241, 6264), True, 'import numpy as np\n'), ((6327, 6381), 'numpy.tile', 'np.tile', (['rand_map_0', '[weight_shape[0] / tile_shape[0]]'], {}), '(rand_map_0, [weight_shape[0] / tile_shape[0]])\n', (6334, 6381), True, 'import numpy as np\n'), ((6399, 6453), 'numpy.tile', 'np.tile', (['rand_map_1', '[weight_shape[0] / tile_shape[0]]'], {}), '(rand_map_1, [weight_shape[0] / tile_shape[0]])\n', (6406, 6453), True, 'import numpy as np\n'), ((6471, 6525), 'numpy.tile', 'np.tile', (['rand_map_2', '[weight_shape[0] / tile_shape[0]]'], {}), '(rand_map_2, [weight_shape[0] / tile_shape[0]])\n', (6478, 6525), True, 'import numpy as np\n'), ((7198, 7236), 'numpy.reshape', 'np.reshape', (['bl_w1_rand_0', 'weight_shape'], {}), '(bl_w1_rand_0, weight_shape)\n', (7208, 7236), True, 'import numpy as np\n'), ((8681, 8699), 'numpy.array', 'np.array', (['bl_gamma'], {}), '(bl_gamma)\n', (8689, 8699), True, 'import numpy as np\n'), ((8718, 8736), 'numpy.array', 'np.array', (['bl_means'], {}), '(bl_means)\n', (8726, 8736), True, 'import numpy as np\n'), ((8762, 8787), 'numpy.array', 'np.array', (['bl_pruning_mask'], {}), '(bl_pruning_mask)\n', (8770, 8787), True, 'import numpy as np\n'), ((13604, 13619), 'numpy.shape', 'np.shape', (['bl_w1'], {}), '(bl_w1)\n', (13612, 13619), True, 'import numpy as np\n'), ((13633, 13650), 'numpy.shape', 'np.shape', (['pret_c1'], {}), '(pret_c1)\n', (13641, 13650), True, 'import numpy as np\n'), ((13663, 13683), 'numpy.zeros', 'np.zeros', (['tile_shape'], {}), '(tile_shape)\n', (13671, 13683), True, 'import numpy as np\n'), ((13695, 13714), 'numpy.ones', 'np.ones', (['tile_shape'], {}), '(tile_shape)\n', (13702, 13714), True, 'import numpy as np\n'), ((13804, 13819), 'numpy.array', 'np.array', (['bl_w1'], {}), '(bl_w1)\n', (13812, 13819), True, 'import numpy as np\n'), ((13828, 13843), 'numpy.array', 'np.array', (['bl_w1'], {}), '(bl_w1)\n', (13836, 13843), True, 'import numpy as np\n'), ((13858, 13882), 'numpy.arange', 'np.arange', (['tile_shape[0]'], {}), '(tile_shape[0])\n', (13867, 13882), True, 'import numpy as np\n'), ((13883, 13912), 'numpy.random.shuffle', 'np.random.shuffle', (['rand_map_0'], {}), '(rand_map_0)\n', (13900, 13912), True, 'import numpy as np\n'), ((13926, 13950), 'numpy.arange', 'np.arange', (['tile_shape[0]'], {}), '(tile_shape[0])\n', (13935, 13950), True, 'import numpy as np\n'), ((13951, 13980), 'numpy.random.shuffle', 'np.random.shuffle', (['rand_map_1'], {}), '(rand_map_1)\n', (13968, 13980), True, 'import numpy as np\n'), ((13994, 14018), 'numpy.arange', 'np.arange', (['tile_shape[0]'], {}), '(tile_shape[0])\n', (14003, 14018), True, 'import numpy as np\n'), ((14019, 14048), 'numpy.random.shuffle', 'np.random.shuffle', (['rand_map_2'], {}), '(rand_map_2)\n', (14036, 14048), True, 'import numpy as np\n'), ((14116, 14156), 'numpy.logical_not', 'np.logical_not', (['pruning_mask[rand_map_0]'], {}), '(pruning_mask[rand_map_0])\n', (14130, 14156), True, 'import numpy as np\n'), ((14259, 14308), 'numpy.logical_or', 'np.logical_or', (['pruning_mask', 'pruning_mask_recover'], {}), '(pruning_mask, pruning_mask_recover)\n', (14272, 14308), True, 'import numpy as np\n'), ((14321, 14354), 'numpy.reshape', 'np.reshape', (['init_mask', 'tile_shape'], {}), '(init_mask, tile_shape)\n', (14331, 14354), True, 'import numpy as np\n'), ((14417, 14471), 'numpy.tile', 'np.tile', (['rand_map_0', '[weight_shape[0] / tile_shape[0]]'], {}), '(rand_map_0, [weight_shape[0] / tile_shape[0]])\n', (14424, 14471), True, 'import numpy as np\n'), ((14489, 14543), 'numpy.tile', 'np.tile', (['rand_map_1', '[weight_shape[0] / tile_shape[0]]'], {}), '(rand_map_1, [weight_shape[0] / tile_shape[0]])\n', (14496, 14543), True, 'import numpy as np\n'), ((14561, 14615), 'numpy.tile', 'np.tile', (['rand_map_2', '[weight_shape[0] / tile_shape[0]]'], {}), '(rand_map_2, [weight_shape[0] / tile_shape[0]])\n', (14568, 14615), True, 'import numpy as np\n'), ((15288, 15326), 'numpy.reshape', 'np.reshape', (['bl_w1_rand_0', 'weight_shape'], {}), '(bl_w1_rand_0, weight_shape)\n', (15298, 15326), True, 'import numpy as np\n'), ((16771, 16789), 'numpy.array', 'np.array', (['bl_gamma'], {}), '(bl_gamma)\n', (16779, 16789), True, 'import numpy as np\n'), ((16808, 16826), 'numpy.array', 'np.array', (['bl_means'], {}), '(bl_means)\n', (16816, 16826), True, 'import numpy as np\n'), ((16852, 16877), 'numpy.array', 'np.array', (['bl_pruning_mask'], {}), '(bl_pruning_mask)\n', (16860, 16877), True, 'import numpy as np\n'), ((21694, 21709), 'numpy.shape', 'np.shape', (['bl_w1'], {}), '(bl_w1)\n', (21702, 21709), True, 'import numpy as np\n'), ((21723, 21740), 'numpy.shape', 'np.shape', (['pret_c1'], {}), '(pret_c1)\n', (21731, 21740), True, 'import numpy as np\n'), ((21753, 21773), 'numpy.zeros', 'np.zeros', (['tile_shape'], {}), '(tile_shape)\n', (21761, 21773), True, 'import numpy as np\n'), ((21785, 21804), 'numpy.ones', 'np.ones', (['tile_shape'], {}), '(tile_shape)\n', (21792, 21804), True, 'import numpy as np\n'), ((21894, 21909), 'numpy.array', 'np.array', (['bl_w1'], {}), '(bl_w1)\n', (21902, 21909), True, 'import numpy as np\n'), ((21918, 21933), 'numpy.array', 'np.array', (['bl_w1'], {}), '(bl_w1)\n', (21926, 21933), True, 'import numpy as np\n'), ((21948, 21972), 'numpy.arange', 'np.arange', (['tile_shape[0]'], {}), '(tile_shape[0])\n', (21957, 21972), True, 'import numpy as np\n'), ((21973, 22002), 'numpy.random.shuffle', 'np.random.shuffle', (['rand_map_0'], {}), '(rand_map_0)\n', (21990, 22002), True, 'import numpy as np\n'), ((22016, 22040), 'numpy.arange', 'np.arange', (['tile_shape[0]'], {}), '(tile_shape[0])\n', (22025, 22040), True, 'import numpy as np\n'), ((22041, 22070), 'numpy.random.shuffle', 'np.random.shuffle', (['rand_map_1'], {}), '(rand_map_1)\n', (22058, 22070), True, 'import numpy as np\n'), ((22084, 22108), 'numpy.arange', 'np.arange', (['tile_shape[0]'], {}), '(tile_shape[0])\n', (22093, 22108), True, 'import numpy as np\n'), ((22109, 22138), 'numpy.random.shuffle', 'np.random.shuffle', (['rand_map_2'], {}), '(rand_map_2)\n', (22126, 22138), True, 'import numpy as np\n'), ((22206, 22246), 'numpy.logical_not', 'np.logical_not', (['pruning_mask[rand_map_0]'], {}), '(pruning_mask[rand_map_0])\n', (22220, 22246), True, 'import numpy as np\n'), ((22349, 22398), 'numpy.logical_or', 'np.logical_or', (['pruning_mask', 'pruning_mask_recover'], {}), '(pruning_mask, pruning_mask_recover)\n', (22362, 22398), True, 'import numpy as np\n'), ((22411, 22444), 'numpy.reshape', 'np.reshape', (['init_mask', 'tile_shape'], {}), '(init_mask, tile_shape)\n', (22421, 22444), True, 'import numpy as np\n'), ((22507, 22561), 'numpy.tile', 'np.tile', (['rand_map_0', '[weight_shape[0] / tile_shape[0]]'], {}), '(rand_map_0, [weight_shape[0] / tile_shape[0]])\n', (22514, 22561), True, 'import numpy as np\n'), ((22579, 22633), 'numpy.tile', 'np.tile', (['rand_map_1', '[weight_shape[0] / tile_shape[0]]'], {}), '(rand_map_1, [weight_shape[0] / tile_shape[0]])\n', (22586, 22633), True, 'import numpy as np\n'), ((22651, 22705), 'numpy.tile', 'np.tile', (['rand_map_2', '[weight_shape[0] / tile_shape[0]]'], {}), '(rand_map_2, [weight_shape[0] / tile_shape[0]])\n', (22658, 22705), True, 'import numpy as np\n'), ((23378, 23416), 'numpy.reshape', 'np.reshape', (['bl_w1_rand_0', 'weight_shape'], {}), '(bl_w1_rand_0, weight_shape)\n', (23388, 23416), True, 'import numpy as np\n'), ((24861, 24879), 'numpy.array', 'np.array', (['bl_gamma'], {}), '(bl_gamma)\n', (24869, 24879), True, 'import numpy as np\n'), ((24898, 24916), 'numpy.array', 'np.array', (['bl_means'], {}), '(bl_means)\n', (24906, 24916), True, 'import numpy as np\n'), ((24942, 24967), 'numpy.array', 'np.array', (['bl_pruning_mask'], {}), '(bl_pruning_mask)\n', (24950, 24967), True, 'import numpy as np\n'), ((29784, 29799), 'numpy.shape', 'np.shape', (['bl_w1'], {}), '(bl_w1)\n', (29792, 29799), True, 'import numpy as np\n'), ((29813, 29830), 'numpy.shape', 'np.shape', (['pret_c1'], {}), '(pret_c1)\n', (29821, 29830), True, 'import numpy as np\n'), ((29843, 29863), 'numpy.zeros', 'np.zeros', (['tile_shape'], {}), '(tile_shape)\n', (29851, 29863), True, 'import numpy as np\n'), ((29875, 29894), 'numpy.ones', 'np.ones', (['tile_shape'], {}), '(tile_shape)\n', (29882, 29894), True, 'import numpy as np\n'), ((29984, 29999), 'numpy.array', 'np.array', (['bl_w1'], {}), '(bl_w1)\n', (29992, 29999), True, 'import numpy as np\n'), ((30008, 30023), 'numpy.array', 'np.array', (['bl_w1'], {}), '(bl_w1)\n', (30016, 30023), True, 'import numpy as np\n'), ((30038, 30062), 'numpy.arange', 'np.arange', (['tile_shape[0]'], {}), '(tile_shape[0])\n', (30047, 30062), True, 'import numpy as np\n'), ((30063, 30092), 'numpy.random.shuffle', 'np.random.shuffle', (['rand_map_0'], {}), '(rand_map_0)\n', (30080, 30092), True, 'import numpy as np\n'), ((30106, 30130), 'numpy.arange', 'np.arange', (['tile_shape[0]'], {}), '(tile_shape[0])\n', (30115, 30130), True, 'import numpy as np\n'), ((30131, 30160), 'numpy.random.shuffle', 'np.random.shuffle', (['rand_map_1'], {}), '(rand_map_1)\n', (30148, 30160), True, 'import numpy as np\n'), ((30174, 30198), 'numpy.arange', 'np.arange', (['tile_shape[0]'], {}), '(tile_shape[0])\n', (30183, 30198), True, 'import numpy as np\n'), ((30199, 30228), 'numpy.random.shuffle', 'np.random.shuffle', (['rand_map_2'], {}), '(rand_map_2)\n', (30216, 30228), True, 'import numpy as np\n'), ((30296, 30336), 'numpy.logical_not', 'np.logical_not', (['pruning_mask[rand_map_0]'], {}), '(pruning_mask[rand_map_0])\n', (30310, 30336), True, 'import numpy as np\n'), ((30439, 30488), 'numpy.logical_or', 'np.logical_or', (['pruning_mask', 'pruning_mask_recover'], {}), '(pruning_mask, pruning_mask_recover)\n', (30452, 30488), True, 'import numpy as np\n'), ((30501, 30534), 'numpy.reshape', 'np.reshape', (['init_mask', 'tile_shape'], {}), '(init_mask, tile_shape)\n', (30511, 30534), True, 'import numpy as np\n'), ((30597, 30651), 'numpy.tile', 'np.tile', (['rand_map_0', '[weight_shape[0] / tile_shape[0]]'], {}), '(rand_map_0, [weight_shape[0] / tile_shape[0]])\n', (30604, 30651), True, 'import numpy as np\n'), ((30669, 30723), 'numpy.tile', 'np.tile', (['rand_map_1', '[weight_shape[0] / tile_shape[0]]'], {}), '(rand_map_1, [weight_shape[0] / tile_shape[0]])\n', (30676, 30723), True, 'import numpy as np\n'), ((30741, 30795), 'numpy.tile', 'np.tile', (['rand_map_2', '[weight_shape[0] / tile_shape[0]]'], {}), '(rand_map_2, [weight_shape[0] / tile_shape[0]])\n', (30748, 30795), True, 'import numpy as np\n'), ((31468, 31506), 'numpy.reshape', 'np.reshape', (['bl_w1_rand_0', 'weight_shape'], {}), '(bl_w1_rand_0, weight_shape)\n', (31478, 31506), True, 'import numpy as np\n'), ((32951, 32969), 'numpy.array', 'np.array', (['bl_gamma'], {}), '(bl_gamma)\n', (32959, 32969), True, 'import numpy as np\n'), ((32988, 33006), 'numpy.array', 'np.array', (['bl_means'], {}), '(bl_means)\n', (32996, 33006), True, 'import numpy as np\n'), ((33032, 33057), 'numpy.array', 'np.array', (['bl_pruning_mask'], {}), '(bl_pruning_mask)\n', (33040, 33057), True, 'import numpy as np\n'), ((34347, 34364), 'numpy.array', 'np.array', (['bl_beta'], {}), '(bl_beta)\n', (34355, 34364), True, 'import numpy as np\n'), ((34380, 34398), 'numpy.array', 'np.array', (['bl_gamma'], {}), '(bl_gamma)\n', (34388, 34398), True, 'import numpy as np\n'), ((34420, 34444), 'numpy.array', 'np.array', (['bl_moving_mean'], {}), '(bl_moving_mean)\n', (34428, 34444), True, 'import numpy as np\n'), ((34470, 34498), 'numpy.array', 'np.array', (['bl_moving_variance'], {}), '(bl_moving_variance)\n', (34478, 34498), True, 'import numpy as np\n'), ((35347, 35364), 'numpy.array', 'np.array', (['bl_beta'], {}), '(bl_beta)\n', (35355, 35364), True, 'import numpy as np\n'), ((35380, 35398), 'numpy.array', 'np.array', (['bl_gamma'], {}), '(bl_gamma)\n', (35388, 35398), True, 'import numpy as np\n'), ((35420, 35444), 'numpy.array', 'np.array', (['bl_moving_mean'], {}), '(bl_moving_mean)\n', (35428, 35444), True, 'import numpy as np\n'), ((35470, 35498), 'numpy.array', 'np.array', (['bl_moving_variance'], {}), '(bl_moving_variance)\n', (35478, 35498), True, 'import numpy as np\n'), ((36347, 36364), 'numpy.array', 'np.array', (['bl_beta'], {}), '(bl_beta)\n', (36355, 36364), True, 'import numpy as np\n'), ((36380, 36398), 'numpy.array', 'np.array', (['bl_gamma'], {}), '(bl_gamma)\n', (36388, 36398), True, 'import numpy as np\n'), ((36420, 36444), 'numpy.array', 'np.array', (['bl_moving_mean'], {}), '(bl_moving_mean)\n', (36428, 36444), True, 'import numpy as np\n'), ((36470, 36498), 'numpy.array', 'np.array', (['bl_moving_variance'], {}), '(bl_moving_variance)\n', (36478, 36498), True, 'import numpy as np\n'), ((37347, 37364), 'numpy.array', 'np.array', (['bl_beta'], {}), '(bl_beta)\n', (37355, 37364), True, 'import numpy as np\n'), ((37380, 37398), 'numpy.array', 'np.array', (['bl_gamma'], {}), '(bl_gamma)\n', (37388, 37398), True, 'import numpy as np\n'), ((37420, 37444), 'numpy.array', 'np.array', (['bl_moving_mean'], {}), '(bl_moving_mean)\n', (37428, 37444), True, 'import numpy as np\n'), ((37470, 37498), 'numpy.array', 'np.array', (['bl_moving_variance'], {}), '(bl_moving_variance)\n', (37478, 37498), True, 'import numpy as np\n'), ((38347, 38364), 'numpy.array', 'np.array', (['bl_beta'], {}), '(bl_beta)\n', (38355, 38364), True, 'import numpy as np\n'), ((38380, 38398), 'numpy.array', 'np.array', (['bl_gamma'], {}), '(bl_gamma)\n', (38388, 38398), True, 'import numpy as np\n'), ((38420, 38444), 'numpy.array', 'np.array', (['bl_moving_mean'], {}), '(bl_moving_mean)\n', (38428, 38444), True, 'import numpy as np\n'), ((38470, 38498), 'numpy.array', 'np.array', (['bl_moving_variance'], {}), '(bl_moving_variance)\n', (38478, 38498), True, 'import numpy as np\n'), ((5641, 5660), 'numpy.ones', 'np.ones', (['tile_shape'], {}), '(tile_shape)\n', (5648, 5660), True, 'import numpy as np\n'), ((6090, 6129), 'numpy.logical_and', 'np.logical_and', (['pruning_mask', 'init_mask'], {}), '(pruning_mask, init_mask)\n', (6104, 6129), True, 'import numpy as np\n'), ((13731, 13750), 'numpy.ones', 'np.ones', (['tile_shape'], {}), '(tile_shape)\n', (13738, 13750), True, 'import numpy as np\n'), ((14180, 14219), 'numpy.logical_and', 'np.logical_and', (['pruning_mask', 'init_mask'], {}), '(pruning_mask, init_mask)\n', (14194, 14219), True, 'import numpy as np\n'), ((21821, 21840), 'numpy.ones', 'np.ones', (['tile_shape'], {}), '(tile_shape)\n', (21828, 21840), True, 'import numpy as np\n'), ((22270, 22309), 'numpy.logical_and', 'np.logical_and', (['pruning_mask', 'init_mask'], {}), '(pruning_mask, init_mask)\n', (22284, 22309), True, 'import numpy as np\n'), ((29911, 29930), 'numpy.ones', 'np.ones', (['tile_shape'], {}), '(tile_shape)\n', (29918, 29930), True, 'import numpy as np\n'), ((30360, 30399), 'numpy.logical_and', 'np.logical_and', (['pruning_mask', 'init_mask'], {}), '(pruning_mask, init_mask)\n', (30374, 30399), True, 'import numpy as np\n'), ((635, 650), 'numpy.array', 'np.array', (['bl_w1'], {}), '(bl_w1)\n', (643, 650), True, 'import numpy as np\n'), ((1064, 1089), 'numpy.array', 'np.array', (['bl_pruning_mask'], {}), '(bl_pruning_mask)\n', (1072, 1089), True, 'import numpy as np\n'), ((5975, 6000), 'numpy.array', 'np.array', (['bl_pruning_mask'], {}), '(bl_pruning_mask)\n', (5983, 6000), True, 'import numpy as np\n'), ((6130, 6152), 'numpy.argsort', 'np.argsort', (['rand_map_0'], {}), '(rand_map_0)\n', (6140, 6152), True, 'import numpy as np\n'), ((8485, 8516), 'numpy.reshape', 'np.reshape', (['rand_map_0', '(-1, 1)'], {}), '(rand_map_0, (-1, 1))\n', (8495, 8516), True, 'import numpy as np\n'), ((8553, 8584), 'numpy.reshape', 'np.reshape', (['rand_map_1', '(-1, 1)'], {}), '(rand_map_1, (-1, 1))\n', (8563, 8584), True, 'import numpy as np\n'), ((8621, 8652), 'numpy.reshape', 'np.reshape', (['rand_map_2', '(-1, 1)'], {}), '(rand_map_2, (-1, 1))\n', (8631, 8652), True, 'import numpy as np\n'), ((8809, 8847), 'numpy.reshape', 'np.reshape', (['rand_map_0_expand', '[-1, 1]'], {}), '(rand_map_0_expand, [-1, 1])\n', (8819, 8847), True, 'import numpy as np\n'), ((8926, 8964), 'numpy.reshape', 'np.reshape', (['rand_map_1_expand', '[-1, 1]'], {}), '(rand_map_1_expand, [-1, 1])\n', (8936, 8964), True, 'import numpy as np\n'), ((9043, 9081), 'numpy.reshape', 'np.reshape', (['rand_map_2_expand', '[-1, 1]'], {}), '(rand_map_2_expand, [-1, 1])\n', (9053, 9081), True, 'import numpy as np\n'), ((9154, 9179), 'numpy.array', 'np.array', (['bl_pruning_mask'], {}), '(bl_pruning_mask)\n', (9162, 9179), True, 'import numpy as np\n'), ((14065, 14090), 'numpy.array', 'np.array', (['bl_pruning_mask'], {}), '(bl_pruning_mask)\n', (14073, 14090), True, 'import numpy as np\n'), ((14220, 14242), 'numpy.argsort', 'np.argsort', (['rand_map_0'], {}), '(rand_map_0)\n', (14230, 14242), True, 'import numpy as np\n'), ((16575, 16606), 'numpy.reshape', 'np.reshape', (['rand_map_0', '(-1, 1)'], {}), '(rand_map_0, (-1, 1))\n', (16585, 16606), True, 'import numpy as np\n'), ((16643, 16674), 'numpy.reshape', 'np.reshape', (['rand_map_1', '(-1, 1)'], {}), '(rand_map_1, (-1, 1))\n', (16653, 16674), True, 'import numpy as np\n'), ((16711, 16742), 'numpy.reshape', 'np.reshape', (['rand_map_2', '(-1, 1)'], {}), '(rand_map_2, (-1, 1))\n', (16721, 16742), True, 'import numpy as np\n'), ((16899, 16937), 'numpy.reshape', 'np.reshape', (['rand_map_0_expand', '[-1, 1]'], {}), '(rand_map_0_expand, [-1, 1])\n', (16909, 16937), True, 'import numpy as np\n'), ((17016, 17054), 'numpy.reshape', 'np.reshape', (['rand_map_1_expand', '[-1, 1]'], {}), '(rand_map_1_expand, [-1, 1])\n', (17026, 17054), True, 'import numpy as np\n'), ((17133, 17171), 'numpy.reshape', 'np.reshape', (['rand_map_2_expand', '[-1, 1]'], {}), '(rand_map_2_expand, [-1, 1])\n', (17143, 17171), True, 'import numpy as np\n'), ((17244, 17269), 'numpy.array', 'np.array', (['bl_pruning_mask'], {}), '(bl_pruning_mask)\n', (17252, 17269), True, 'import numpy as np\n'), ((22155, 22180), 'numpy.array', 'np.array', (['bl_pruning_mask'], {}), '(bl_pruning_mask)\n', (22163, 22180), True, 'import numpy as np\n'), ((22310, 22332), 'numpy.argsort', 'np.argsort', (['rand_map_0'], {}), '(rand_map_0)\n', (22320, 22332), True, 'import numpy as np\n'), ((24665, 24696), 'numpy.reshape', 'np.reshape', (['rand_map_0', '(-1, 1)'], {}), '(rand_map_0, (-1, 1))\n', (24675, 24696), True, 'import numpy as np\n'), ((24733, 24764), 'numpy.reshape', 'np.reshape', (['rand_map_1', '(-1, 1)'], {}), '(rand_map_1, (-1, 1))\n', (24743, 24764), True, 'import numpy as np\n'), ((24801, 24832), 'numpy.reshape', 'np.reshape', (['rand_map_2', '(-1, 1)'], {}), '(rand_map_2, (-1, 1))\n', (24811, 24832), True, 'import numpy as np\n'), ((24989, 25027), 'numpy.reshape', 'np.reshape', (['rand_map_0_expand', '[-1, 1]'], {}), '(rand_map_0_expand, [-1, 1])\n', (24999, 25027), True, 'import numpy as np\n'), ((25106, 25144), 'numpy.reshape', 'np.reshape', (['rand_map_1_expand', '[-1, 1]'], {}), '(rand_map_1_expand, [-1, 1])\n', (25116, 25144), True, 'import numpy as np\n'), ((25223, 25261), 'numpy.reshape', 'np.reshape', (['rand_map_2_expand', '[-1, 1]'], {}), '(rand_map_2_expand, [-1, 1])\n', (25233, 25261), True, 'import numpy as np\n'), ((25334, 25359), 'numpy.array', 'np.array', (['bl_pruning_mask'], {}), '(bl_pruning_mask)\n', (25342, 25359), True, 'import numpy as np\n'), ((30245, 30270), 'numpy.array', 'np.array', (['bl_pruning_mask'], {}), '(bl_pruning_mask)\n', (30253, 30270), True, 'import numpy as np\n'), ((30400, 30422), 'numpy.argsort', 'np.argsort', (['rand_map_0'], {}), '(rand_map_0)\n', (30410, 30422), True, 'import numpy as np\n'), ((32755, 32786), 'numpy.reshape', 'np.reshape', (['rand_map_0', '(-1, 1)'], {}), '(rand_map_0, (-1, 1))\n', (32765, 32786), True, 'import numpy as np\n'), ((32823, 32854), 'numpy.reshape', 'np.reshape', (['rand_map_1', '(-1, 1)'], {}), '(rand_map_1, (-1, 1))\n', (32833, 32854), True, 'import numpy as np\n'), ((32891, 32922), 'numpy.reshape', 'np.reshape', (['rand_map_2', '(-1, 1)'], {}), '(rand_map_2, (-1, 1))\n', (32901, 32922), True, 'import numpy as np\n'), ((33079, 33117), 'numpy.reshape', 'np.reshape', (['rand_map_0_expand', '[-1, 1]'], {}), '(rand_map_0_expand, [-1, 1])\n', (33089, 33117), True, 'import numpy as np\n'), ((33196, 33234), 'numpy.reshape', 'np.reshape', (['rand_map_1_expand', '[-1, 1]'], {}), '(rand_map_1_expand, [-1, 1])\n', (33206, 33234), True, 'import numpy as np\n'), ((33313, 33351), 'numpy.reshape', 'np.reshape', (['rand_map_2_expand', '[-1, 1]'], {}), '(rand_map_2_expand, [-1, 1])\n', (33323, 33351), True, 'import numpy as np\n'), ((33424, 33449), 'numpy.array', 'np.array', (['bl_pruning_mask'], {}), '(bl_pruning_mask)\n', (33432, 33449), True, 'import numpy as np\n'), ((1109, 1134), 'numpy.array', 'np.array', (['bl_pruning_mask'], {}), '(bl_pruning_mask)\n', (1117, 1134), True, 'import numpy as np\n'), ((9199, 9224), 'numpy.array', 'np.array', (['bl_pruning_mask'], {}), '(bl_pruning_mask)\n', (9207, 9224), True, 'import numpy as np\n'), ((17289, 17314), 'numpy.array', 'np.array', (['bl_pruning_mask'], {}), '(bl_pruning_mask)\n', (17297, 17314), True, 'import numpy as np\n'), ((25379, 25404), 'numpy.array', 'np.array', (['bl_pruning_mask'], {}), '(bl_pruning_mask)\n', (25387, 25404), True, 'import numpy as np\n'), ((33469, 33494), 'numpy.array', 'np.array', (['bl_pruning_mask'], {}), '(bl_pruning_mask)\n', (33477, 33494), True, 'import numpy as np\n')]