Flipkart-inspired sequence model receives padded item histories where padding positions must not influence the representation. You need to compute the mean over only the unmasked positions so downstream ranking features are not biased by padding.
X holds one embedding per row of a padded sequence and mask[i] is 1 (or True) for real positions and 0 for padding. Return the average of the real embeddings only. If no position is real, return the zero vector.
Implement solve(X,mask).
Returns. Return a float NumPy vector of length X.shape[1].
Example 1
Input:
solve([[1, 2], [3, 4], [9, 9]], [1, 1, 0])
Output:
[2.0, 3.0]
Example 2
Input:
solve([[5.0, 5.0]], [0])
Output:
[0.0, 0.0]
No results yet
Run your code to check it against the examples, or submit to run every test.