创建 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)