Python tensorflow.python.client.session.BaseSession() Examples
The following are 13
code examples of tensorflow.python.client.session.BaseSession().
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: session_context.py From parallax with Apache License 2.0 | 6 votes |
def set_parallax_session_context(self): self.old_run = getattr(session.BaseSession, 'run', None) self.old_init = getattr(session.BaseSession, '__init__', None) if not self.old_run: raise tf.errors.InternalError(None, None, 'BaseSession misses run method.') elif not self.old_init: raise tf.errors.InternalError(None, None, 'BaseSession misses __init__ method.') elif getattr(session.BaseSession, '_run_internal', None): raise tf.errors.InternalError(None, None, 'Already in context or context not cleaned.') elif getattr(session.BaseSession, '_init_internal', None): raise tf.errors.InternalError(None, None, 'Already in context or context not cleaned.') else: setattr(session.BaseSession, 'run', _parallax_run) setattr(session.BaseSession, '__init__', _parallax_init) setattr(session.BaseSession, '_run_internal', self.old_run) setattr(session.BaseSession, '_init_internal', self.old_init) setattr(session.BaseSession, 'parallax_session_context', self) return self
Example #2
Source File: profile_context.py From Serverless-Deep-Learning-with-TensorFlow-and-AWS-Lambda with MIT License | 6 votes |
def __enter__(self): self.old_run = getattr(session.BaseSession, 'run', None) self.old_init = getattr(session.BaseSession, '__init__', None) if not self.old_run: raise errors.InternalError(None, None, 'BaseSession misses run method.') elif not self.old_init: raise errors.InternalError(None, None, 'BaseSession misses __init__ method.') elif getattr(session.BaseSession, '_profiler_run_internal', None): raise errors.InternalError(None, None, 'Already in context or context not cleaned.') elif getattr(session.BaseSession, '_profiler_init_internal', None): raise errors.InternalError(None, None, 'Already in context or context not cleaned.') else: setattr(session.BaseSession, 'run', _profiled_run) setattr(session.BaseSession, '__init__', _profiled_init) setattr(session.BaseSession, '_profiler_run_internal', self.old_run) setattr(session.BaseSession, '_profiler_init_internal', self.old_init) setattr(session.BaseSession, 'profile_context', self) return self
Example #3
Source File: framework.py From lambda-packs with MIT License | 5 votes |
def __init__(self, sess): """Constructor. Args: sess: A tensorflow Session object. """ _check_type(sess, session.BaseSession) self.session = sess
Example #4
Source File: framework.py From auto-alt-text-lambda-api with MIT License | 5 votes |
def __init__(self, sess): """Constructor. Args: sess: A tensorflow Session object. """ _check_type(sess, session.BaseSession) self.session = sess
Example #5
Source File: framework.py From auto-alt-text-lambda-api with MIT License | 5 votes |
def __init__(self, sess): """Constructor of `BaseDebugWrapperSession`. Args: sess: An (unwrapped) TensorFlow session instance. Raises: ValueError: On invalid `OnSessionInitAction` value. NotImplementedError: If a non-DirectSession sess object is received. """ _check_type(sess, session.BaseSession) # TODO(cais): Remove this check once tfdbg is integrated with GrpcSession. if sess.sess_str: raise NotImplementedError( "Non-DirectSession support is not available from TensorFlow " "Debugger yet (sess_str=%s)" % sess.sess_str) # The session being wrapped. self._sess = sess # Keeps track of number of run calls that have been performed on this # debug-wrapper session. self._run_call_count = 0 # Invoke on-session-init callback. response = self.on_session_init(OnSessionInitRequest(self._sess)) _check_type(response, OnSessionInitResponse) if response.action == OnSessionInitAction.PROCEED: pass elif response.action == OnSessionInitAction.REMOTE_INSTR_LOOP: # TODO(cais): Implement REMOTE_INSTR_LOOP raise NotImplementedError( "OnSessionInitAction REMOTE_INSTR_LOOP has not been " "implemented.") else: raise ValueError( "Invalid OnSessionInitAction value: %s" % response.action)
Example #6
Source File: framework.py From deep_image_model with Apache License 2.0 | 5 votes |
def __init__(self, sess): """Constructor. Args: sess: A tensorflow Session object. """ _check_type(sess, session.BaseSession) self.session = sess
Example #7
Source File: framework.py From deep_image_model with Apache License 2.0 | 5 votes |
def __init__(self, sess): """Constructor of BaseDebugWrapperSession. Args: sess: An (unwrapped) TensorFlow session instance. Raises: ValueError: On invalid OnSessionInitAction value. """ _check_type(sess, session.BaseSession) # The session being wrapped. self._sess = sess # Keeps track of number of run calls that have been performed on this # debug-wrapper session. self._run_call_count = 0 # Invoke on-session-init callback. response = self.on_session_init(OnSessionInitRequest(self._sess)) _check_type(response, OnSessionInitResponse) if response.action == OnSessionInitAction.PROCEED: pass elif response.action == OnSessionInitAction.REMOTE_INSTR_LOOP: # TODO(cais): Implement REMOTE_INSTR_LOOP raise NotImplementedError( "OnSessionInitAction REMOTE_INSTR_LOOP has not been " "implemented.") else: raise ValueError( "Invalid OnSessionInitAction value: %s" % response.action)
Example #8
Source File: framework.py From Serverless-Deep-Learning-with-TensorFlow-and-AWS-Lambda with MIT License | 5 votes |
def __init__(self, sess): """Constructor. Args: sess: A tensorflow Session object. """ _check_type(sess, (session.BaseSession, monitored_session.MonitoredSession)) self.session = sess
Example #9
Source File: profile_context.py From Serverless-Deep-Learning-with-TensorFlow-and-AWS-Lambda with MIT License | 5 votes |
def __exit__(self, exec_type, exec_value, exec_tb): print_mdl.DeleteProfiler() setattr(session.BaseSession, 'run', self.old_run) setattr(session.BaseSession, '__init__', self.old_init) setattr(session.BaseSession, '_profiler_run_internal', None) setattr(session.BaseSession, '_profiler_init_internal', None) setattr(session.BaseSession, 'profile_context', None)
Example #10
Source File: framework.py From keras-lambda with MIT License | 5 votes |
def __init__(self, sess): """Constructor. Args: sess: A tensorflow Session object. """ _check_type(sess, session.BaseSession) self.session = sess
Example #11
Source File: framework.py From keras-lambda with MIT License | 5 votes |
def __init__(self, sess): """Constructor of `BaseDebugWrapperSession`. Args: sess: An (unwrapped) TensorFlow session instance. Raises: ValueError: On invalid `OnSessionInitAction` value. NotImplementedError: If a non-DirectSession sess object is received. """ _check_type(sess, session.BaseSession) # TODO(cais): Remove this check once tfdbg is integrated with GrpcSession. if sess.sess_str: raise NotImplementedError( "Non-DirectSession support is not available from TensorFlow " "Debugger yet (sess_str=%s)" % sess.sess_str) # The session being wrapped. self._sess = sess # Keeps track of number of run calls that have been performed on this # debug-wrapper session. self._run_call_count = 0 # Invoke on-session-init callback. response = self.on_session_init(OnSessionInitRequest(self._sess)) _check_type(response, OnSessionInitResponse) if response.action == OnSessionInitAction.PROCEED: pass elif response.action == OnSessionInitAction.REMOTE_INSTR_LOOP: # TODO(cais): Implement REMOTE_INSTR_LOOP raise NotImplementedError( "OnSessionInitAction REMOTE_INSTR_LOOP has not been " "implemented.") else: raise ValueError( "Invalid OnSessionInitAction value: %s" % response.action)
Example #12
Source File: framework.py From lambda-packs with MIT License | 4 votes |
def __init__(self, sess, thread_name_filter=None): """Constructor of `BaseDebugWrapperSession`. Args: sess: An (unwrapped) TensorFlow session instance. thread_name_filter: Regular-expression filter (whitelist) for name(s) of thread(s) on which the wrapper session will be active. This regular expression is used in a start-anchored fashion on the thread name, i.e., by applying the `match` method of the compiled pattern. The default `None` means that the wrapper session will be active on all threads. E.g., r"MainThread$", r"QueueRunnerThread.*". Raises: ValueError: On invalid `OnSessionInitAction` value. NotImplementedError: If a non-DirectSession sess object is received. """ _check_type(sess, session.BaseSession) # The session being wrapped. self._sess = sess self._thread_name_filter_pattern = (re.compile(thread_name_filter) if thread_name_filter else None) # Keeps track of number of run calls that have been performed on this # debug-wrapper session. self._run_call_count = 0 # Invoke on-session-init callback. response = self.on_session_init(OnSessionInitRequest(self._sess)) _check_type(response, OnSessionInitResponse) if response.action == OnSessionInitAction.PROCEED: pass elif response.action == OnSessionInitAction.REMOTE_INSTR_LOOP: # TODO(cais): Implement REMOTE_INSTR_LOOP raise NotImplementedError( "OnSessionInitAction REMOTE_INSTR_LOOP has not been " "implemented.") else: raise ValueError( "Invalid OnSessionInitAction value: %s" % response.action)
Example #13
Source File: framework.py From Serverless-Deep-Learning-with-TensorFlow-and-AWS-Lambda with MIT License | 4 votes |
def __init__(self, sess, thread_name_filter=None, pass_through_operrors=False): """Constructor of `BaseDebugWrapperSession`. Args: sess: An (unwrapped) TensorFlow session instance. It should be a subtype of `BaseSession` or `tf.MonitoredSession`. thread_name_filter: Regular-expression filter (whitelist) for name(s) of thread(s) on which the wrapper session will be active. This regular expression is used in a start-anchored fashion on the thread name, i.e., by applying the `match` method of the compiled pattern. The default `None` means that the wrapper session will be active on all threads. E.g., r"MainThread$", r"QueueRunnerThread.*". pass_through_operrors: If True, all captured OpErrors will be propagated. By default this captures all OpErrors. Raises: ValueError: On invalid `OnSessionInitAction` value. NotImplementedError: If a non-DirectSession sess object is received. """ _check_type(sess, (session.BaseSession, monitored_session.MonitoredSession)) # The session being wrapped. self._sess = sess self._thread_name_filter_pattern = (re.compile(thread_name_filter) if thread_name_filter else None) # TODO(cais/kstevens): Unittest this pass through feature. self._pass_through_operrors = pass_through_operrors # Keeps track of number of run calls that have been performed on this # debug-wrapper session. The count can be used for purposes such as # displaying the state of the Session in a UI and determining a run # number-dependent debug URL. self._run_call_count = 0 # Invoke on-session-init callback. response = self.on_session_init(OnSessionInitRequest(self._sess)) _check_type(response, OnSessionInitResponse) if response.action == OnSessionInitAction.PROCEED: pass elif response.action == OnSessionInitAction.REMOTE_INSTR_LOOP: # TODO(cais): Implement REMOTE_INSTR_LOOP raise NotImplementedError( "OnSessionInitAction REMOTE_INSTR_LOOP has not been " "implemented.") else: raise ValueError( "Invalid OnSessionInitAction value: %s" % response.action) self._default_session_context_manager = None