batch_size * n random indices that run from
batch_size- Number of items in each batch
n- Number of random indices in each example
n_max- Maximum index (excluded)
A uniformly distributed integer tensor of indices
Flattens all but last dimension of
x so it becomes 2D.
x- Any tensor with at least 2 dimensions
The reshaped tensor, where all but the last dimension are flattened into the first dimension
Gathers candidate values according to IDs.
x- Any tensor with at least one dimension
candidate_ids- Indicator for which candidates to gather
A tensor of shape
(batch_size, 1, num_candidates, tf.shape(x)[-1]), where
for each batch example, we generate a list of
num_candidates vectors, and
each candidate is chosen from
x according to the candidate id. For example:
Computes the mean number of matches between x and y.
n dimensions, then the mean equal
number of indices is calculated for the last dimension by
only taking the valid indices into consideration
(from the mask) and then it is averaged over all
For e.g., if:
x = [[1,2,3,4][5,6,7,8]] y = [[1,2,3,4][5,6,0,0]] mask = [[1,1,1,1], [1,1,1,0]]
then the output will be calculated as
((4/4) + 2/3) / 2
x- Any numeric tensor.
y- Another tensor with same shape and type as x.
mask- Tensor with a mask to distinguish actual indices from padding indices. Shape should be the same as
The mean of "x == y"