def load_weights(self, model):
    for i in range(106):
        try:
            conv_layer = model.get_layer(('conv_' + str(i)))
            print(('loading weights of convolution #' + str(i)))
            if (i not in [81, 93, 105]):
                norm_layer = model.get_layer(('bnorm_' + str(i)))
                size = np.prod(norm_layer.get_weights()[0].shape)
                beta = self.read_bytes(size)
                gamma = self.read_bytes(size)
                mean = self.read_bytes(size)
                var = self.read_bytes(size)
                weights = norm_layer.set_weights([gamma, beta, mean, var])
            if (len(conv_layer.get_weights()) > 1):
                bias = self.read_bytes(np.prod(conv_layer.get_weights()[1].shape))
                kernel = self.read_bytes(np.prod(conv_layer.get_weights()[0].shape))
                kernel = kernel.reshape(list(reversed(conv_layer.get_weights()[0].shape)))
                kernel = kernel.transpose([2, 3, 1, 0])
                conv_layer.set_weights([kernel, bias])
            else:
                kernel = self.read_bytes(np.prod(conv_layer.get_weights()[0].shape))
                kernel = kernel.reshape(list(reversed(conv_layer.get_weights()[0].shape)))
                kernel = kernel.transpose([2, 3, 1, 0])
                conv_layer.set_weights([kernel])
        except ValueError:
            print(('no convolution #' + str(i)))
def load_weights(self, model):
    for i in range(106):
        try:
            conv_layer = model.get_layer(('conv_' + str(i)))
            print(('loading weights of convolution #' + str(i)))
            if (i not in [81, 93, 105]):
                norm_layer = model.get_layer(('bnorm_' + str(i)))
                size = np.prod(norm_layer.get_weights()[0].shape)
                beta = self.read_bytes(size)
                gamma = self.read_bytes(size)
                mean = self.read_bytes(size)
                var = self.read_bytes(size)
                weights = norm_layer.set_weights([gamma, beta, mean, var])
            if (len(conv_layer.get_weights()) > 1):
                bias = self.read_bytes(np.prod(conv_layer.get_weights()[1].shape))
                kernel = self.read_bytes(np.prod(conv_layer.get_weights()[0].shape))
                kernel = kernel.reshape(list(reversed(conv_layer.get_weights()[0].shape)))
                kernel = kernel.transpose([2, 3, 1, 0])
                conv_layer.set_weights([kernel, bias])
            else:
                kernel = self.read_bytes(np.prod(conv_layer.get_weights()[0].shape))
                kernel = kernel.reshape(list(reversed(conv_layer.get_weights()[0].shape)))
                kernel = kernel.transpose([2, 3, 1, 0])
                conv_layer.set_weights([kernel])
        except ValueError:
            print(('no convolution #' + str(i)))