def setup_session(self, server, hooks, graph_default_context):
        """
        Creates and then enters the session for this model (finalizes the graph).

        Args:
            server (tf.train.Server): The tf.train.Server object to connect to (None for single execution).
            hooks (list): A list of (saver, summary, etc..) hooks to be passed to the session.
            graph_default_context: The graph as_default() context that we are currently in.
        """
        if self.execution_type == "distributed":
            # if self.distributed_spec['task_index'] == 0:
            # TensorFlow chief session creator object
            session_creator = tf.train.ChiefSessionCreator(
                scaffold=self.scaffold,
                master=server.target,
                config=self.session_config,
                checkpoint_dir=None,
                checkpoint_filename_with_path=None
            )
            # else:
            #     # TensorFlow worker session creator object
            #     session_creator = tf.train.WorkerSessionCreator(
            #         scaffold=self.scaffold,
            #         master=server.target,
            #         config=self.execution_spec.get('session_config'),
            #     )

            # TensorFlow monitored session object
            self.monitored_session = tf.train.MonitoredSession(
                session_creator=session_creator,
                hooks=hooks,
                stop_grace_period_secs=120  # Default value.
            )
            # Add debug session.run dumping?
            if self.tf_session_dump_dir != "":
                self.monitored_session = DumpingDebugWrapperSession(self.monitored_session, self.tf_session_dump_dir)
        else:
            # TensorFlow non-distributed monitored session object
            self.monitored_session = tf.train.SingularMonitoredSession(
                hooks=hooks,
                scaffold=self.scaffold,
                master='',  # Default value.
                config=self.session_config,  # self.execution_spec.get('session_config'),
                checkpoint_dir=None
            )

        if graph_default_context:
            graph_default_context.__exit__(None, None, None)
        self.graph.finalize()

        # enter the session to be ready for acting/learning
        self.monitored_session.__enter__()
        self.session = self.monitored_session._tf_sess()
def setup_session(self, server, hooks, graph_default_context):
        """
        Creates and then enters the session for this model (finalizes the graph).

        Args:
            server (tf.train.Server): The tf.train.Server object to connect to (None for single execution).
            hooks (list): A list of (saver, summary, etc..) hooks to be passed to the session.
            graph_default_context: The graph as_default() context that we are currently in.
        """
        if self.execution_type == "distributed":
            # if self.distributed_spec['task_index'] == 0:
            # TensorFlow chief session creator object
            session_creator = tf.train.ChiefSessionCreator(
                scaffold=self.scaffold,
                master=server.target,
                config=self.session_config,
                checkpoint_dir=None,
                checkpoint_filename_with_path=None
            )
            # else:
            #     # TensorFlow worker session creator object
            #     session_creator = tf.train.WorkerSessionCreator(
            #         scaffold=self.scaffold,
            #         master=server.target,
            #         config=self.execution_spec.get('session_config'),
            #     )

            # TensorFlow monitored session object
            self.monitored_session = tf.train.MonitoredSession(
                session_creator=session_creator,
                hooks=hooks,
                stop_grace_period_secs=120  # Default value.
            )
            # Add debug session.run dumping?
            if self.tf_session_dump_dir != "":
                self.monitored_session = DumpingDebugWrapperSession(self.monitored_session, self.tf_session_dump_dir)
        else:
            # TensorFlow non-distributed monitored session object
            self.monitored_session = tf.train.SingularMonitoredSession(
                hooks=hooks,
                scaffold=self.scaffold,
                master='',  # Default value.
                config=self.session_config,  # self.execution_spec.get('session_config'),
                checkpoint_dir=None
            )

        if graph_default_context:
            graph_default_context.__exit__(None, None, None)
        self.graph.finalize()

        # enter the session to be ready for acting/learning
        self.monitored_session.__enter__()
        self.session = self.monitored_session._tf_sess()
def setup_session ( self , server , hooks , graph_default_context ) : if self . execution_type == "distributed" : # if self.distributed_spec['task_index'] == 0: # TensorFlow chief session creator object session_creator = tf . train . ChiefSessionCreator ( scaffold = self . scaffold , master = server . target , config = self . session_config , checkpoint_dir = None , checkpoint_filename_with_path = None ) # else: #     # TensorFlow worker session creator object #     session_creator = tf.train.WorkerSessionCreator( #         scaffold=self.scaffold, #         master=server.target, #         config=self.execution_spec.get('session_config'), #     ) # TensorFlow monitored session object self . monitored_session = tf . train . MonitoredSession ( session_creator = session_creator , hooks = hooks , stop_grace_period_secs = 120 # Default value. ) # Add debug session.run dumping? if self . tf_session_dump_dir != "" : self . monitored_session = DumpingDebugWrapperSession ( self . monitored_session , self . tf_session_dump_dir ) else : # TensorFlow non-distributed monitored session object self . monitored_session = tf . train . SingularMonitoredSession ( hooks = hooks , scaffold = self . scaffold , master = '' , # Default value. config = self . session_config , # self.execution_spec.get('session_config'), checkpoint_dir = None ) if graph_default_context : graph_default_context . __exit__ ( None , None , None ) self . graph . finalize ( ) # enter the session to be ready for acting/learning self . monitored_session . __enter__ ( ) self . session = self . monitored_session . _tf_sess ( )
Creates and then enters the session for this model (finalizes the graph).

        Args:
            server (tf.train.Server): The tf.train.Server object to connect to (None for single execution).
            hooks (list): A list of (saver, summary, etc..) hooks to be passed to the session.
            graph_default_context: The graph as_default() context that we are currently in.
Creates and then enters the session for this model ( finalizes the graph ) .