This line should the other way around. If weights is None then don't unpacked from the input
basselkassem opened this issue · 2 comments
basselkassem commented
aheydon-google commented
Hi, Bassel, thanks for the report.
This is a bit confusing, but I actually think the code is correct. The documentation says:
Args:
inputs: Symbolic inputs. Should be (sources, targets) if `weights` is
non-symbolic. Otherwise, should be (sources, targets, weights).
weights: If target weights are not symbolic, `weights` should be passed as
a separate argument. In this case, `inputs` should have length 2.
The idea is that if you pass None for weights, the inputs argument is expected to be a tuple of 3 elements; otherwise, it's expected to be a tuple of 2 elements. And that's just what the code does:
if weights is None:
sources, targets, weights = inputs
else:
sources, targets = inputs
(Notice in the else case that the weights variable is left unchanged because it already has a non-None value.)
So I'm going to close this bug as I believe the code is correct. Please feel free to re-open it if you think I'm mistaken.
Thanks!
basselkassem commented
Thank you Aheydon for your replay. I get it know!