New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
sampled_softmax_loss weights and logits don't get gradients #41792
Comments
I have tried in colab with TF version 2.2,2.3-rc2 .Please, find the gist here.You are also seeing the same behavior? |
Yes that's exactly the output I get (just with a different random initialization). |
Was able to reproduce the issue in TF v2.5,please find the gist here..Thanks ! |
I was able to reproduce the issue on TF 2.12.0-dev20221114 , Attaching Gist for reference. |
@mohantym from your gist it looks to me it looks that the weights and biases are the same after the first batch and at the end:
|
System information
Describe the current behavior
In order to use
tf.nn.sampled_softmax_loss
weights and biases need to be provided as inputs. I believe internally rows from those tensors are selected based on the samples and hte computation is performed.The problem is that if you create a model with a final Dense layer and provide the weights and biases of that layer as input to
tf.nn.sampled_softmax_loss
, you end up receving a warning that gradients for them are not computed:As a consequence, they never get updated during training.
Describe the expected behavior
Gradients for those tensors should be computed and they should get updated.
Standalone code to reproduce the issue
The text was updated successfully, but these errors were encountered: