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

Function TestShapeAttribute

tensorflow/go/op/op_test.go:62–94  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

60}
61
62func TestShapeAttribute(t *testing.T) {
63 s := NewScope()
64 x := Placeholder(s.SubScope("x"), tf.Int32, PlaceholderShape(tf.MakeShape(1)))
65 y := Placeholder(s.SubScope("y"), tf.Int32, PlaceholderShape(tf.Shape{}))
66 z := Add(s, x, y)
67 graph, err := s.Finalize()
68 if err != nil {
69 t.Fatal(err)
70 }
71 sess, err := tf.NewSession(graph, nil)
72 if err != nil {
73 t.Fatal(err)
74 }
75
76 value, err := tf.NewTensor([]int32{7})
77 if err != nil {
78 t.Fatal(err)
79 }
80 feeds := map[tf.Output]*tf.Tensor{
81 x: value,
82 y: value,
83 }
84 fetched, err := sess.Run(feeds, []tf.Output{z}, nil)
85 if err != nil {
86 t.Fatal(err)
87 }
88 if got, want := len(fetched), 1; got != want {
89 t.Fatalf("Fetched %d tensors, expected %d", got, want)
90 }
91 if got, want := fetched[0].Value().([]int32), []int32{14}; len(got) != len(want) || len(got) != 1 || got[0] != want[0] {
92 t.Fatalf("Got %v, want %v", got, want)
93 }
94}
95
96func TestDataset(t *testing.T) {
97 var (

Callers

nothing calls this directly

Calls 10

SubScopeMethod · 0.95
FinalizeMethod · 0.95
RunMethod · 0.95
NewScopeFunction · 0.85
PlaceholderShapeFunction · 0.85
PlaceholderFunction · 0.70
AddFunction · 0.70
MakeShapeMethod · 0.45
NewSessionMethod · 0.45
ValueMethod · 0.45

Tested by

no test coverage detected