Tensorflow Study Note, Part Three

Session

  1. Interactive Session

tf.InteractiveSession() creates a default session that can be used without explictly called in a IPython environment

Example:

tf.InteractiveSession()
a = tf.constant(1)
a.eval()

  1. Regular Session

Regular session needs to be run within a python context or through session object

Example 1:

a = tf.constant(1)
sess = tf.Session()
sess.run(a)

Example 2:

a = tf.constant(1)
with tf.Session():
a.eval()

tf.add_bias

This function is used to add bias to the input tensor (element-wise addition between "bias" vector and the feature vector)

It should be noted that the bias added here is completed different from the normal concept of adding a bias to the hidden unit (summed weight before activation)

tf.Session

The run function of tf.Session provides a interface to execute provided TF operations and evaluate Tensors.

Feature Preprocessing

Continuous features can be feed into the first hidden layer of the neural network directly. Discrete features are recommended to go through an embedding layer.

embed_sequence

This API accepts a [batch_size, doc_length] tensor of type "int32" or "int64"

embedding_lookup

This API is used to loopup an embedding using ID.

Categorial to Embedding Pipeline

Categorial Label ---> Ordinal ID ---> One-hot Embedding ----> Dense Embedding

Leave a Reply

Your email address will not be published. Required fields are marked *