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

Method as_default

tensorflow/python/framework/ops.py:3840–3880  ·  view source on GitHub ↗

Returns a context manager that makes this `Graph` the default graph. This method should be used if you want to create multiple graphs in the same process. For convenience, a global default graph is provided, and all ops will be added to this graph if you do not create a new graph ex

(self)

Source from the content-addressed store, hash-verified

3838 return op_def
3839
3840 def as_default(self):
3841 """Returns a context manager that makes this `Graph` the default graph.
3842
3843 This method should be used if you want to create multiple graphs
3844 in the same process. For convenience, a global default graph is
3845 provided, and all ops will be added to this graph if you do not
3846 create a new graph explicitly.
3847
3848 Use this method with the `with` keyword to specify that ops created within
3849 the scope of a block should be added to this graph. In this case, once
3850 the scope of the `with` is exited, the previous default graph is set again
3851 as default. There is a stack, so it's ok to have multiple nested levels
3852 of `as_default` calls.
3853
3854 The default graph is a property of the current thread. If you
3855 create a new thread, and wish to use the default graph in that
3856 thread, you must explicitly add a `with g.as_default():` in that
3857 thread's function.
3858
3859 The following code examples are equivalent:
3860
3861 ```python
3862 # 1. Using Graph.as_default():
3863 g = tf.Graph()
3864 with g.as_default():
3865 c = tf.constant(5.0)
3866 assert c.graph is g
3867
3868 # 2. Constructing and making default:
3869 with tf.Graph().as_default() as g:
3870 c = tf.constant(5.0)
3871 assert c.graph is g
3872 ```
3873
3874 If eager execution is enabled ops created under this context manager will be
3875 added to the graph instead of executed eagerly.
3876
3877 Returns:
3878 A context manager for using this graph as the default graph.
3879 """
3880 return _default_graph_stack.get_controller(self)
3881
3882 @property
3883 def collections(self):

Callers 15

setUpMethod · 0.95
create_test_networkFunction · 0.95
create_test_network_1Function · 0.95
create_test_network_2Function · 0.95
create_test_network_3Function · 0.95
create_test_network_4Function · 0.95
create_test_network_5Function · 0.95
create_test_network_6Function · 0.95
create_test_network_7Function · 0.95
create_test_network_8Function · 0.95

Calls 1

get_controllerMethod · 0.45

Tested by 15

setUpMethod · 0.76
create_test_networkFunction · 0.76
create_test_network_1Function · 0.76
create_test_network_2Function · 0.76
create_test_network_3Function · 0.76
create_test_network_4Function · 0.76
create_test_network_5Function · 0.76
create_test_network_6Function · 0.76
create_test_network_7Function · 0.76
create_test_network_8Function · 0.76