Exception in thread "main" org.tensorflow.exceptions.TensorFlowException: No gradient defined for op: SelectV2.
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 4/5
- Temps estimé
- 3-5 jours
- Accessibilité débutants
- 30/100
- Type d'issue
- Bug
- Clarté
- À clarifier
- Activité
- À l'abandon
- Domaine
- machine-learning
Piste de recherche
Commencez par le code fourni de clipByNormTF et callOne ainsi que par la trace de la pile passant par Graph.addGradients, Gradients.create et Ops.gradients. Reproduisez l’échec de SelectV2 avec tensorflow-java 0.5.0-SNAPSHOT, Scala 2.12.11 et JDK 15 ; le travail est terminé lorsque le comportement du gradient ou un correctif approprié est vérifié.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
env :
tensorflow-java : 0.5.0-SNAPSHOT
scala :2.12.11
java : jdk 15
Hi :
when I defined a tf Variable named embeddings ,and want to do some operation with it, invoke the callone method
def clipByNormTF[T <: TNumber](someNums: Operand[T], clipNormBias: Operand[T], axis: Operand[TInt32], tf: Ops): Output[TFloat32] = {
try {
val l2sum = tf.reduceSum(tf.math.square(tf.dtypes.cast(someNums, classOf[TFloat64])), axis, ReduceSum.keepDims(true))
val pred = tf.math.greater(l2sum, tf.constant(0.0))
println("Here will crash !!! please ")
val l2sumSafe = tf.select(pred, l2sum, tf.onesLike(l2sum))
val l2norm = tf.select(pred, tf.math.sqrt(l2sumSafe), l2sum)
val intermediate = tf.math.mul(tf.dtypes.cast(someNums, classOf[TFloat64]), tf.dtypes.cast(clipNormBias, classOf[TFloat64]))
val valuesClip = tf.identity(tf.math.divNoNan(intermediate, tf.math.maximum(l2norm, tf.dtypes.cast(clipNormBias, classOf[TFloat64]))))
if (someNums.shape().isCompatibleWith(intermediate.shape())) {
println(s"match the shape ${someNums.shape().get(0)} ${someNums.shape().get(1)} || ${intermediate.shape().get(0)} ${intermediate.shape().get(1)}")
tf.dtypes.cast(valuesClip, classOf[TFloat32]).asOutput()
} else {
println(s"can not match the shape ${someNums.shape().get(0)} ${someNums.shape().get(1)} || ${intermediate.shape().get(0)} ${intermediate.shape().get(1)}")
throw new Exception("bad shape")
}
}
def callOne(tf: Ops, input: Operand[T]): Operand[TFloat32] = {
println(s"Embedding Layer ${this.layerName} input compute shape ${input.shape().asArray().mkString("|")}")
val inputZ = tf.dtypes.cast(input, classOf[TInt32])
val gatherResult = tf.gather(this.embeddings, inputZ, tf.constant(0))
val gr = tf.dtypes.cast(gatherResult, classOf[TFloat32])
val result = clipByNormTF(gr, tf.constant(this.maxNormBias), tf.constant(Array(1, 0)), tf)
println(s"Embedding Layer call result shape ${this.layerName} compute output shape ${result.shape().asArray().mkString("|")}")
result
}
meet to error console
Exception in thread "main" org.tensorflow.exceptions.TensorFlowException: No gradient defined for op: SelectV2. Please see https://www.tensorflow.org/code/tensorflow/cc/gradients/README.md for instructions on how to add C++ gradients.
at org.tensorflow.internal.c_api.AbstractTF_Status.throwExceptionIfNotOK(AbstractTF_Status.java:101)
at org.tensorflow.Graph.addGradients(Graph.java:1152)
at org.tensorflow.Graph.addGradients(Graph.java:703)
at org.tensorflow.op.core.Gradients.create(Gradients.java:104)
at org.tensorflow.op.core.Gradients.create(Gradients.java:125)
at org.tensorflow.op.Ops.gradients(Ops.java:2814)
I do not know why , feel appreciate help me ,thanks
- Langage dominant
- Java
- Étoiles
- 928
- Forks
- 227
- Métriques de merge des PR
- Aucune PR mergée en 30 j
Guide de contribution
Ouvrir le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de tensorflow/java
-
Difficulté 2/5 1-3 heures Accessibilité débutants 65/100
tensorflow/java#653 · 1 commentaire · 4 réactions ·
-
Difficulté 5/5 Plus d'une semaine Accessibilité débutants 25/100
tensorflow/java#621 · 4 commentaires ·
-
Difficulté 5/5 Plus d'une semaine Accessibilité débutants 25/100
tensorflow/java#617 · 3 commentaires ·
-
Difficulté 2/5 1-3 heures Accessibilité débutants 55/100
tensorflow/java#615 · 1 commentaire ·
-
Difficulté 5/5 Plus d'une semaine Accessibilité débutants 25/100
tensorflow/java#614 · 1 commentaire ·
Toutes les issues de tensorflow/java
Issues similaires
-
Bug Java Platform: Java
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
getsentry/sentry-java#6138 · 1 commentaire ·
-
bug needs triage p2
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
GoogleCloudPlatform/DataflowTemplates#4273 · 1 commentaire ·
-
[Studio][Bug] Bulk-deleting a full page of alert rules steps the page back while more rules remain Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
apache/rocketmq-dashboard#4654 · 1 commentaire ·
-
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
-
Difficulté 2/5 1-3 heures Accessibilité débutants 76/100