I am trying to reconcile information from the TF "Graphs and Sessions" Guide and the TF "Keras" Guide and TF Estimators Guides. Now in the former it says that the a tf.Session gives the computation graph access to the physical hardware to execute the graph and train the model. Like the initial tutorials on learning TF require you to use a Session in order to run anything: variables guide, Tensors guide, etc. HOWEVER, in the TF Keras guide, the examples seem to run without any explicit call to the tf.Session or the usual with tf.Session() as sess: The Keras model is not using eager execution either. The same is true in for the Estimators API.
I have a couple of code samples. Some of them use the call to the session while others do not. I was hoping someone could clarify what are the rules for requirements for using tf.Session with Keras layers or Estimators. I mean it seems like you can set up things like run_configs for the keras estimator or standard TF.estimator and set the settings for multi-gpu, etc.
Here is an example from the TF Keras Guide for the Functional API. Note that no call is made to the session:
inputs = tf.keras.Input(shape=(32,)) # Returns a placeholder tensor
# A layer instance is callable on a tensor, and returns a tensor.
x = layers.Dense(64, activation='relu')(inputs)
x = layers.Dense(64, activation='relu')(x)
predictions = layers.Dense(10, activation='softmax')(x)
model = tf.keras.Model(inputs=inputs, outputs=predictions)
# The compile step specifies the training configuration.
model.compile(optimizer=tf.train.RMSPropOptimizer(0.001),
loss='categorical_crossentropy',
metrics=['accuracy'])
# Trains for 5 epochs
model.fit(data, labels, batch_size=32, epochs=100)
Thanks for any info or clarifications.