MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / TestValidateGradientsNames

Function TestValidateGradientsNames

tensorflow/go/op/gradients_test.go:188–216  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

186}
187
188func TestValidateGradientsNames(t *testing.T) {
189 var (
190 s = NewScope()
191 x = Placeholder(s.SubScope("x"), tf.Float)
192 y0 = Square(s.SubScope("y0"), x)
193 )
194
195 grads0 := Gradients(s, []tf.Output{y0}, []tf.Output{x})
196 if err := s.Err(); err != nil {
197 t.Fatal(err)
198 }
199 if !strings.HasPrefix(grads0[0].Op.Name(), "Gradients/") {
200 t.Fatalf("Got name %v, wanted started with Gradients/", grads0[0].Op.Name())
201 }
202
203 sub := s.SubScope("sub")
204 grads1 := Gradients(sub, []tf.Output{y0}, []tf.Output{x})
205 if err := s.Err(); err != nil {
206 t.Fatal(err)
207 }
208 if !strings.HasPrefix(grads1[0].Op.Name(), "sub/Gradients/") {
209 t.Fatalf("Got name %v, wanted started with sub/Gradients/", grads1[0].Op.Name())
210 }
211
212 Gradients(sub, []tf.Output{y0}, []tf.Output{x})
213 if err := s.Err(); err == nil {
214 t.Error("Gradients should have failed if executed more than once for scope of the same namespace")
215 }
216}
217
218func TestAddGradientsWithControlDependencies(t *testing.T) {
219 var (

Callers

nothing calls this directly

Calls 8

NewScopeFunction · 0.85
SubScopeMethod · 0.80
PlaceholderFunction · 0.70
SquareFunction · 0.70
GradientsFunction · 0.70
ErrMethod · 0.45
NameMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected