def testL2GroupingRegularizer(self): group_reg = grouping_regularizers.L2GroupingRegularizer( [self._reg1, self._reg2], 0.25) expcted_reg_vec = [ np.sqrt((x**2 + y**2)) for x, y in zip(self._reg_vec1, self._reg_vec2) ] with self.test_session(): self.assertAllEqual([x > 0.25 for x in expcted_reg_vec], group_reg.alive_vector.eval()) self.assertAllClose(expcted_reg_vec, group_reg.regularization_vector.eval(), 1e-5)
def _l2_reg_with_025_threshold(regularizers_to_group): return grouping_regularizers.L2GroupingRegularizer(regularizers_to_group, 0.25)