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

Method testFeedAndFetch

tensorflow/python/client/session_test.py:1404–1448  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1402 self.assertAllEqual(a2_val, [[1.0, 1.0]])
1403
1404 def testFeedAndFetch(self):
1405 with session.Session() as sess:
1406 for dtype in [
1407 dtypes.float16, dtypes.float32, dtypes.float64, dtypes.int32,
1408 dtypes.uint8, dtypes.int16, dtypes.int8, dtypes.int64, dtypes.bool,
1409 dtypes.complex64, dtypes.complex128
1410 ]:
1411 for shape in [(32, 4, 128), (37,), (2, 0, 6), (0, 0, 0)]:
1412 np_dtype = dtype.as_numpy_dtype
1413
1414 feed_t = array_ops.placeholder(dtype=dtype, shape=shape)
1415 out_t = array_ops.identity(feed_t)
1416
1417 np_array = np.random.randint(-10, 10, shape)
1418
1419 if dtype == dtypes.bool:
1420 np_array = np_array > 0
1421 elif dtype == dtypes.complex64:
1422 np_array = np.sqrt(np_array.astype(np_dtype))
1423 elif dtype == dtypes.complex64:
1424 np_array = np.sqrt(np_array.astype(np_dtype))
1425 else:
1426 np_array = np_array.astype(np_dtype)
1427
1428 self.assertAllEqual(np_array,
1429 sess.run(out_t, feed_dict={
1430 feed_t: np_array
1431 }))
1432 # Check that we can also get the feed back.
1433 self.assertAllEqual(np_array,
1434 sess.run(feed_t, feed_dict={
1435 feed_t: np_array
1436 }))
1437 # Also check that we can get both back.
1438 out_v, feed_v = sess.run(
1439 [out_t, feed_t], feed_dict={
1440 feed_t: np_array
1441 })
1442 self.assertAllEqual(np_array, out_v)
1443 self.assertAllEqual(np_array, feed_v)
1444
1445 feed_fetch_runner = sess.make_callable([out_t, feed_t], [feed_t])
1446 out_v, feed_v = feed_fetch_runner(np_array)
1447 self.assertAllEqual(np_array, out_v)
1448 self.assertAllEqual(np_array, feed_v)
1449
1450 def testMakeCallableOnTensorWithRunOptions(self):
1451 with session.Session() as sess:

Callers

nothing calls this directly

Calls 6

SessionMethod · 0.45
placeholderMethod · 0.45
identityMethod · 0.45
assertAllEqualMethod · 0.45
runMethod · 0.45
make_callableMethod · 0.45

Tested by

no test coverage detected