建立 Softmax 輸出層
當 state_below 是 2D Tensor 時,U 是 2D 權重矩陣,b 是 class_size-length 向量:
logits = tf.matmul(state_below, U) + b
return tf.nn.softmax(logits)
當 state_below 是 3D 張量時,U,b 和以前一樣:
def softmax_fn(current_input):
logits = tf.matmul(current_input, U) + b
return tf.nn.softmax(logits)
raw_preds = tf.map_fn(softmax_fn, state_below)