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

Method __init__

tensorflow/python/client/session.py:637–707  ·  view source on GitHub ↗

Constructs a new TensorFlow session. Args: target: (Optional) The TensorFlow execution engine to connect to. graph: (Optional) The graph to be used. If this argument is None, the default graph will be used. config: (Optional) ConfigProto proto used to configure the ses

(self, target='', graph=None, config=None)

Source from the content-addressed store, hash-verified

635 """
636
637 def __init__(self, target='', graph=None, config=None):
638 """Constructs a new TensorFlow session.
639
640 Args:
641 target: (Optional) The TensorFlow execution engine to connect to.
642 graph: (Optional) The graph to be used. If this argument is None, the
643 default graph will be used.
644 config: (Optional) ConfigProto proto used to configure the session. If no
645 config is specified, the global default will be used. The global default
646 can be configured via the tf.config APIs.
647
648 Raises:
649 tf.errors.OpError: Or one of its subclasses if an error occurs while
650 creating the TensorFlow session.
651 TypeError: If one of the arguments has the wrong type.
652 """
653 _python_session_create_counter.get_cell().increase_by(1)
654 if graph is None:
655 self._graph = ops.get_default_graph()
656 else:
657 if not isinstance(graph, ops.Graph):
658 raise TypeError('graph must be a tf.Graph, but got %s' % type(graph))
659 self._graph = graph
660
661 self._closed = False
662
663 if target is not None:
664 try:
665 self._target = compat.as_bytes(target)
666 except TypeError:
667 if isinstance(target, config_pb2.ConfigProto):
668 raise TypeError('target must be a string, but got %s.'
669 ' Did you do "Session(config)" instead of'
670 ' "Session(config=config)"?' % type(target))
671 raise TypeError('target must be a string, but got %s' % type(target))
672 else:
673 self._target = None
674
675 self._delete_lock = threading.Lock()
676 self._dead_handles = []
677
678 if config is None:
679 config = context.context().config
680
681 if not isinstance(config, config_pb2.ConfigProto):
682 raise TypeError('config must be a tf.ConfigProto, but got %s' %
683 type(config))
684
685 if (mixed_precision_global_state.mixed_precision_graph_rewrite_is_enabled
686 and config.graph_options.rewrite_options.auto_mixed_precision !=
687 rewriter_config_pb2.RewriterConfig.OFF):
688 new_config = config_pb2.ConfigProto()
689 new_config.CopyFrom(config)
690 new_config.graph_options.rewrite_options.auto_mixed_precision = (
691 rewriter_config_pb2.RewriterConfig.ON)
692 config = new_config
693 elif (config.graph_options.rewrite_options.auto_mixed_precision !=
694 rewriter_config_pb2.RewriterConfig.ON):

Callers

nothing calls this directly

Calls 6

typeFunction · 0.85
increase_byMethod · 0.80
LockMethod · 0.80
get_cellMethod · 0.45
contextMethod · 0.45
CopyFromMethod · 0.45

Tested by

no test coverage detected