@@ -807,7 +807,7 @@ def SessionConfig(soft_placement=True,
807807
808808
809809def AssertIsCompatible (a , b ):
810- assert a .IsCompatible (b ), ( '%s vs %s' % (a , b ) )
810+ assert a .IsCompatible (b ), '%s vs %s' % (a , b )
811811
812812
813813def SetShapes (dst_nmap : NestedMap , src_nmap : NestedMap ) -> None :
@@ -1602,7 +1602,7 @@ def VariableShapePrefixContext(shape_prefix):
16021602 Yields:
16031603 None.
16041604 """
1605- assert shape_prefix > 0 , ( '%s' % shape_prefix )
1605+ assert shape_prefix > 0 , '%s' % shape_prefix
16061606 _VARIABLE_SHAPE_PREFIXES .stack .append (shape_prefix )
16071607 try :
16081608 yield
@@ -1920,7 +1920,6 @@ def _CreateVariableStateful(name,
19201920 with tf .variable_scope (name ) as scope :
19211921 var_name = GetVariableName (scope .name )
19221922
1923- global_seed = None
19241923 if tf .executing_eagerly () and _EAGER_RNG_ADAPTATION :
19251924 # Equivalent to graph mode `tf.get_default_graph().seed`
19261925 # Refer to `tf.get_seed` implementation
@@ -3576,7 +3575,7 @@ def CombineMetrics(loss_metric_weight_pairs):
35763575 result = {}
35773576 for k in all_keys :
35783577 count = 0
3579- for loss_metrics , weight in loss_metric_weight_pairs :
3578+ for loss_metrics , _ in loss_metric_weight_pairs :
35803579 if k in loss_metrics :
35813580 count += 1
35823581 if count > 1 and count != len (loss_metric_weight_pairs ):
@@ -3694,7 +3693,7 @@ def DisableVN():
36943693@contextlib .contextmanager
36953694def StepSeedIncrementContext (step ):
36963695 """Adds an element to _STEP_SEED_INCREMENT."""
3697- assert step > 0 , ( '%s' % step )
3696+ assert step > 0 , '%s' % step
36983697 _STEP_SEED_INCREMENT .stack .append (step )
36993698 try :
37003699 yield
@@ -3815,7 +3814,7 @@ def DeterministicDropout(x, keep_prob, seeds, noise_shape=None, name=None):
38153814
38163815 if keep_prob == 1 :
38173816 return x
3818- with tf .name_scope (name , 'dropout' , [x ]) as name :
3817+ with tf .name_scope (name , 'dropout' , [x ]):
38193818 if use_tpu ():
38203819 seeds = tf .cast (seeds , tf .int32 )
38213820 keep_prob = tf .convert_to_tensor (
@@ -3851,7 +3850,7 @@ def DeterministicVN(params, noise_shape, mean=0.0, std=1.0, name=None):
38513850 A Tensor with the shape noise_shape and type fprop_dtype.
38523851 """
38533852
3854- with tf .name_scope (name , 'gaussian_noise' ) as name :
3853+ with tf .name_scope (name , 'gaussian_noise' ):
38553854 seeds = GenerateStepSeedPair (params , params .vn .seed )
38563855 random_tensor = mean + (
38573856 std * tf .random .stateless_normal (noise_shape , seed = seeds ))
@@ -4587,7 +4586,6 @@ def ExpandAndPadOrTrimTo(x, target_shape, pad_val=0):
45874586 """
45884587 if x is None :
45894588 return None
4590- target_rank = None
45914589 if isinstance (target_shape , tf .Tensor ):
45924590 target_rank = GetShape (target_shape )[0 ]
45934591 else :
@@ -5269,7 +5267,7 @@ def ProjectLastDim(inputs, weight, input_dim, output_dim, use_einsum=True):
52695267@contextlib .contextmanager
52705268def RemoveAssertContext (remove = True ):
52715269 """Hacks to replace certain unwanted tensorflow ops."""
5272- # TODO(zhifengc/ huangyp): Consider implementing assert_equal
5270+ # TODO(zhifengc) TODO( huangyp): Consider implementing assert_equal
52735271 # op replacement for lingvo. As assert_equal doesn't support String on GPUs.
52745272 # Hack to replace tf.assert_equal
52755273 # TODO(b/136040013): Remove this after migration to tf.function.
@@ -5830,8 +5828,6 @@ def __init__(self,
58305828 """
58315829 self ._fwd_sig = fwd_sig
58325830
5833- wrapped_fwd_sig = fwd_sig
5834- fwd_fn = fwd
58355831 bak_fn = bak
58365832
58375833 graph_random_seed = None
0 commit comments