@@ -33,7 +33,7 @@ def dropped_inputs() -> tf.Tensor:
33
33
34
34
35
35
class DenseForSparse (tf .keras .layers .Dense ):
36
- """Dense layer for sparse input tensor"""
36
+ """Dense layer for sparse input tensor. """
37
37
38
38
def __init__ (self , reg_lambda : float = 0 , ** kwargs ) -> None :
39
39
if reg_lambda > 0 :
@@ -171,6 +171,7 @@ def call(
171
171
training : Optional [Union [tf .Tensor , bool ]] = None ,
172
172
) -> Tuple [tf .Tensor , tf .Tensor ]:
173
173
"""Randomly mask input sequences."""
174
+
174
175
if training is None :
175
176
training = K .learning_phase ()
176
177
@@ -279,6 +280,7 @@ def _make_flat(x: tf.Tensor) -> tf.Tensor:
279
280
def _random_indices (self , batch_size : tf .Tensor , total_candidates : tf .Tensor ):
280
281
def rand_idxs ():
281
282
"""Create random tensor of indices"""
283
+
282
284
# (1, num_neg)
283
285
return tf .expand_dims (
284
286
tf .random .shuffle (tf .range (total_candidates ))[: self .num_neg ], 0
@@ -450,7 +452,7 @@ def _train_sim(
450
452
451
453
@staticmethod
452
454
def _calc_accuracy (sim_pos : tf .Tensor , sim_neg : tf .Tensor ) -> tf .Tensor :
453
- """Calculate accuracy"""
455
+ """Calculate accuracy. """
454
456
455
457
max_all_sim = tf .reduce_max (tf .concat ([sim_pos , sim_neg ], - 1 ), - 1 )
456
458
return tf .reduce_mean (
0 commit comments