Returns the TF session to be used by the backend. If a default TensorFlow session is available, we will return it. Else, we will return the global Keras session assuming it matches the current graph. If no global Keras session exists at this point: we will create a new global session.
(op_input_list=())
| 459 | |
| 460 | @keras_export(v1=['keras.backend.get_session']) |
| 461 | def get_session(op_input_list=()): |
| 462 | """Returns the TF session to be used by the backend. |
| 463 | |
| 464 | If a default TensorFlow session is available, we will return it. |
| 465 | |
| 466 | Else, we will return the global Keras session assuming it matches |
| 467 | the current graph. |
| 468 | |
| 469 | If no global Keras session exists at this point: |
| 470 | we will create a new global session. |
| 471 | |
| 472 | Note that you can manually set the global session |
| 473 | via `K.set_session(sess)`. |
| 474 | |
| 475 | Arguments: |
| 476 | op_input_list: An option sequence of tensors or ops, which will be used |
| 477 | to determine the current graph. Otherwise the default graph will be |
| 478 | used. |
| 479 | |
| 480 | Returns: |
| 481 | A TensorFlow session. |
| 482 | """ |
| 483 | session = _get_session(op_input_list) |
| 484 | if not _MANUAL_VAR_INIT: |
| 485 | with session.graph.as_default(): |
| 486 | _initialize_variables(session) |
| 487 | return session |
| 488 | |
| 489 | |
| 490 | def get_graph(): |
no test coverage detected