Пример #1
0
 def mn(weights, name=None):
   """Applies max-norm regularization to weights."""
   try: # TF12
       with ops.name_scope(scope, 'maxnorm_regularizer', [weights]) as name:
         my_scale = ops.convert_to_tensor(scale,
                                          dtype=weights.dtype.base_dtype,
                                          name='scale')
         return standard_ops.mul(my_scale, standard_ops.reduce_max(standard_ops.abs(weights)), name=scope)
   except: # TF11
       with ops.op_scope([weights], name, 'maxnorm_regularizer') as scope:
         my_scale = ops.convert_to_tensor(scale,
                                          dtype=weights.dtype.base_dtype,
                                          name='scale')
         return standard_ops.mul(my_scale, standard_ops.reduce_max(standard_ops.abs(weights)), name=scope)
Пример #2
0
 def mn(weights, name=None):
   """Applies max-norm regularization to weights."""
   with ops.op_scope([weights], name, 'maxnorm_regularizer') as scope:
     my_scale = ops.convert_to_tensor(scale,
                                      dtype=weights.dtype.base_dtype,
                                      name='scale')
     return standard_ops.mul(my_scale, standard_ops.reduce_max(standard_ops.abs(weights)), name=scope)
Пример #3
0
 def mn(weights, name='max_regularizer'):
     """Applies max-norm regularization to weights."""
     with tf.name_scope(name) as scope:
         my_scale = ops.convert_to_tensor(scale, dtype=weights.dtype.base_dtype, name='scale')
         #   if tf.__version__ <= '0.12':
         #       standard_ops_fn = standard_ops.mul
         #   else:
         standard_ops_fn = standard_ops.multiply
         return standard_ops_fn(my_scale, standard_ops.reduce_max(standard_ops.abs(weights)), name=scope)
Пример #4
0
 def mn(weights, name='max_regularizer'):
     """Applies max-norm regularization to weights."""
     with tf.name_scope(name) as scope:
         my_scale = ops.convert_to_tensor(scale, dtype=weights.dtype.base_dtype, name='scale')
         #   if tf.__version__ <= '0.12':
         #       standard_ops_fn = standard_ops.mul
         #   else:
         standard_ops_fn = standard_ops.multiply
         return standard_ops_fn(my_scale, standard_ops.reduce_max(standard_ops.abs(weights)), name=scope)
Пример #5
0
 def l1(weights, name=None):
   """Applies L1 regularization to weights."""
   with ops.name_scope(scope, 'l1_regularizer', [weights]) as name:
     my_scale = ops.convert_to_tensor(scale,
                                      dtype=weights.dtype.base_dtype,
                                      name='scale')
     return standard_ops.mul(
         my_scale,
         standard_ops.reduce_sum(standard_ops.abs(weights)),
         name=name)
Пример #6
0
 def mn_i(weights, name=None):
     """Applies max-norm regularization to weights."""
     with ops.op_scope([weights], name, 'maxnorm_o_regularizer') as scope:
         my_scale = ops.convert_to_tensor(scale,
                                          dtype=weights.dtype.base_dtype,
                                          name='scale')
         return standard_ops.mul(my_scale,
                                 standard_ops.reduce_sum(
                                     standard_ops.reduce_max(
                                         standard_ops.abs(weights), 1)),
                                 name=scope)
 def _distribution(self, state):
   distribution = _maximal_eigenvector_power_method(
       self._stochastic_matrix(state))
   distribution = standard_ops.abs(distribution)
   distribution /= standard_ops.reduce_sum(distribution)
   return distribution
Пример #8
0
 def _distribution(self, state):
   distribution = _maximal_eigenvector_power_method(
       self._stochastic_matrix(state))
   distribution = standard_ops.abs(distribution)
   distribution /= standard_ops.reduce_sum(distribution)
   return distribution
Пример #9
0
 def l1(weights, name=None):
     """Applies L1 regularization to weights."""
     with ops.op_scope([weights], name, "l1_regularizer") as scope:
         my_scale = ops.convert_to_tensor(scale, dtype=weights.dtype.base_dtype, name="scale")
         return standard_ops.mul(my_scale, standard_ops.reduce_sum(standard_ops.abs(weights)), name=scope)