def _blockMasking(self, hparams, weights, expected_mask):
    threshold = variables.VariableV1(0.0, name='threshold')
    sparsity = variables.VariableV1(0.5, name='sparsity')
    test_spec = ','.join(hparams)
    pruning_hparams = pruning.get_pruning_hparams().parse(test_spec)
    p = pruning.Pruning(pruning_hparams, sparsity=sparsity)
    with self.cached_session():
        variables.global_variables_initializer().run()
        (_, new_mask) = p._maybe_update_block_mask(weights, threshold)
        self.assertAllEqual(new_mask.get_shape(), weights.get_shape())
        mask_val = new_mask.eval()
        self.assertAllEqual(mask_val, expected_mask)
def _blockMasking(self, hparams, weights, expected_mask):
    threshold = variables.VariableV1(0.0, name='threshold')
    sparsity = variables.VariableV1(0.5, name='sparsity')
    test_spec = ','.join(hparams)
    pruning_hparams = pruning.get_pruning_hparams().parse(test_spec)
    p = pruning.Pruning(pruning_hparams, sparsity=sparsity)
    with self.cached_session():
        variables.global_variables_initializer().run()
        (_, new_mask) = p._maybe_update_block_mask(weights, threshold)
        self.assertAllEqual(new_mask.get_shape(), weights.get_shape())
        mask_val = new_mask.eval()
        self.assertAllEqual(mask_val, expected_mask)