# tf.get_default_session

<br />

|---|
| [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v1.15.0/tensorflow/python/framework/ops.py#L5352-L5367) |

Returns the default session for the current thread.

#### View aliases


**Compat aliases for migration**

See
[Migration guide](https://www.tensorflow.org/guide/migrate) for
more details.

[`tf.compat.v1.get_default_session`](https://www.tensorflow.org/api_docs/python/tf/compat/v1/get_default_session)

<br />

    tf.get_default_session()

The returned `Session` will be the innermost session on which a
`Session` or [`Session.as_default()`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/InteractiveSession#as_default) context has been entered.

> [!NOTE]
> **Note:** The default session is a property of the current thread. If you create a new thread, and wish to use the default session in that thread, you must explicitly add a `with sess.as_default():` in that thread's function.

<br />

<br />

<br />

| ## Returns ||
|---|---|
| The default `Session` being used in the current thread. ||

<br />