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

Function TestDataset

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

Source from the content-addressed store, hash-verified

94}
95
96func TestDataset(t *testing.T) {
97 var (
98 s = NewScope()
99
100 // The use of a non-scalar here is inspired by
101 // https://github.com/tensorflow/tensorflow/issues/14891
102 c = Const(s, []int32{21718, 31415})
103 types = []tf.DataType{c.DataType()}
104 shapes = []tf.Shape{c.Shape()}
105 dataset = TensorDataset(s, []tf.Output{c}, shapes)
106
107 iterator = Iterator(s, "", "", types, shapes)
108 next = IteratorGetNext(s, iterator, types, shapes)
109 init = MakeIterator(s, dataset, iterator)
110 )
111 graph, err := s.Finalize()
112 if err != nil {
113 t.Fatal(err)
114 }
115 sess, err := tf.NewSession(graph, nil)
116 if err != nil {
117 t.Fatal(err)
118 }
119 if _, err := sess.Run(nil, nil, []*tf.Operation{init}); err != nil {
120 t.Fatal(err)
121 }
122 results, err := sess.Run(nil, next, nil)
123 if err != nil {
124 t.Fatal(err)
125 }
126 got := results[0].Value().([]int32)
127 if len(got) != 2 || got[0] != 21718 || got[1] != 31415 {
128 t.Errorf("Got %v, want {21718, 31415}", got)
129 }
130 if _, err := sess.Run(nil, next, nil); err == nil {
131 t.Errorf("Expected sess.Run() to fail since the iterator should have reached the end of the dataset")
132 }
133}

Callers

nothing calls this directly

Calls 12

RunMethod · 0.95
NewScopeFunction · 0.85
IteratorGetNextFunction · 0.85
MakeIteratorFunction · 0.85
ConstFunction · 0.70
TensorDatasetFunction · 0.70
IteratorFunction · 0.70
DataTypeMethod · 0.45
ShapeMethod · 0.45
FinalizeMethod · 0.45
NewSessionMethod · 0.45
ValueMethod · 0.45

Tested by

no test coverage detected