Python tensorflow.python.client.session.SessionInterface() Examples
The following are 5
code examples of tensorflow.python.client.session.SessionInterface().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
tensorflow.python.client.session
, or try the search function
.
Example #1
Source File: framework_test.py From auto-alt-text-lambda-api with MIT License | 6 votes |
def testSessionInit(self): self.assertEqual(0, self._observer["sess_init_count"]) wrapper_sess = TestDebugWrapperSession(self._sess, self._dump_root, self._observer) # Assert that on-session-init callback is invoked. self.assertEqual(1, self._observer["sess_init_count"]) # Assert that the request to the on-session-init callback carries the # correct session object. self.assertEqual(self._sess, self._observer["request_sess"]) # Verify that the wrapper session implements the session.SessionInterface. self.assertTrue(isinstance(wrapper_sess, session.SessionInterface)) self.assertEqual(self._sess.sess_str, wrapper_sess.sess_str) self.assertEqual(self._sess.graph, wrapper_sess.graph) # Check that the partial_run_setup and partial_run are not implemented for # the debug wrapper session. with self.assertRaises(NotImplementedError): wrapper_sess.partial_run_setup(self._p)
Example #2
Source File: framework_test.py From deep_image_model with Apache License 2.0 | 6 votes |
def testSessionInit(self): self.assertEqual(0, self._observer["sess_init_count"]) wrapper_sess = TestDebugWrapperSession(self._sess, self._dump_root, self._observer) # Assert that on-session-init callback is invoked. self.assertEqual(1, self._observer["sess_init_count"]) # Assert that the request to the on-session-init callback carries the # correct session object. self.assertEqual(self._sess, self._observer["request_sess"]) # Verify that the wrapper session implements the session.SessionInterface. self.assertTrue(isinstance(wrapper_sess, session.SessionInterface)) self.assertEqual(self._sess.sess_str, wrapper_sess.sess_str) self.assertEqual(self._sess.graph, wrapper_sess.graph) # Check that the partial_run_setup and partial_run are not implemented for # the debug wrapper session. with self.assertRaises(NotImplementedError): wrapper_sess.partial_run_setup(self._p)
Example #3
Source File: framework_test.py From keras-lambda with MIT License | 6 votes |
def testSessionInit(self): self.assertEqual(0, self._observer["sess_init_count"]) wrapper_sess = TestDebugWrapperSession(self._sess, self._dump_root, self._observer) # Assert that on-session-init callback is invoked. self.assertEqual(1, self._observer["sess_init_count"]) # Assert that the request to the on-session-init callback carries the # correct session object. self.assertEqual(self._sess, self._observer["request_sess"]) # Verify that the wrapper session implements the session.SessionInterface. self.assertTrue(isinstance(wrapper_sess, session.SessionInterface)) self.assertEqual(self._sess.sess_str, wrapper_sess.sess_str) self.assertEqual(self._sess.graph, wrapper_sess.graph) # Check that the partial_run_setup and partial_run are not implemented for # the debug wrapper session. with self.assertRaises(NotImplementedError): wrapper_sess.partial_run_setup(self._p)
Example #4
Source File: queue_runner_impl.py From lambda-packs with MIT License | 4 votes |
def start_queue_runners(sess=None, coord=None, daemon=True, start=True, collection=ops.GraphKeys.QUEUE_RUNNERS): """Starts all queue runners collected in the graph. This is a companion method to `add_queue_runner()`. It just starts threads for all queue runners collected in the graph. It returns the list of all threads. Args: sess: `Session` used to run the queue ops. Defaults to the default session. coord: Optional `Coordinator` for coordinating the started threads. daemon: Whether the threads should be marked as `daemons`, meaning they don't block program exit. start: Set to `False` to only create the threads, not start them. collection: A `GraphKey` specifying the graph collection to get the queue runners from. Defaults to `GraphKeys.QUEUE_RUNNERS`. Raises: ValueError: if `sess` is None and there isn't any default session. TypeError: if `sess` is not a `tf.Session` object. Returns: A list of threads. """ if sess is None: sess = ops.get_default_session() if not sess: raise ValueError("Cannot start queue runners: No default session is " "registered. Use `with sess.as_default()` or pass an " "explicit session to tf.start_queue_runners(sess=sess)") if not isinstance(sess, session.SessionInterface): # Following check is due to backward compatibility. (b/62061352) if sess.__class__.__name__ in [ "MonitoredSession", "SingularMonitoredSession"]: return [] raise TypeError("sess must be a `tf.Session` object. " "Given class: {}".format(sess.__class__)) with sess.graph.as_default(): threads = [] for qr in ops.get_collection(collection): threads.extend(qr.create_threads(sess, coord=coord, daemon=daemon, start=start)) return threads
Example #5
Source File: queue_runner_impl.py From Serverless-Deep-Learning-with-TensorFlow-and-AWS-Lambda with MIT License | 4 votes |
def start_queue_runners(sess=None, coord=None, daemon=True, start=True, collection=ops.GraphKeys.QUEUE_RUNNERS): """Starts all queue runners collected in the graph. This is a companion method to `add_queue_runner()`. It just starts threads for all queue runners collected in the graph. It returns the list of all threads. Args: sess: `Session` used to run the queue ops. Defaults to the default session. coord: Optional `Coordinator` for coordinating the started threads. daemon: Whether the threads should be marked as `daemons`, meaning they don't block program exit. start: Set to `False` to only create the threads, not start them. collection: A `GraphKey` specifying the graph collection to get the queue runners from. Defaults to `GraphKeys.QUEUE_RUNNERS`. Raises: ValueError: if `sess` is None and there isn't any default session. TypeError: if `sess` is not a `tf.Session` object. Returns: A list of threads. """ if sess is None: sess = ops.get_default_session() if not sess: raise ValueError("Cannot start queue runners: No default session is " "registered. Use `with sess.as_default()` or pass an " "explicit session to tf.start_queue_runners(sess=sess)") if not isinstance(sess, session.SessionInterface): # Following check is due to backward compatibility. (b/62061352) if sess.__class__.__name__ in [ "MonitoredSession", "SingularMonitoredSession"]: return [] raise TypeError("sess must be a `tf.Session` object. " "Given class: {}".format(sess.__class__)) with sess.graph.as_default(): threads = [] for qr in ops.get_collection(collection): threads.extend(qr.create_threads(sess, coord=coord, daemon=daemon, start=start)) return threads