Minor simplification in alignment_matrix_from_pharaoh
@@ -394,13 +394,13 @@ def alignment_matrix_from_pharaoh(alignment_line,
align_pairs_flat_str = tf.string_split(align_pairs_str, delimiter="-").values
align_pairs_flat = tf.string_to_number(align_pairs_flat_str, out_type=tf.int32)
sparse_indices = tf.reshape(align_pairs_flat, [-1, 2])
- sparse_values = tf.ones([tf.shape(sparse_indices)[0]])
+ sparse_values = tf.ones([tf.shape(sparse_indices)[0]], dtype=dtype)
alignment_matrix = tf.sparse_to_dense(
sparse_indices,
[source_length, target_length],
sparse_values,
validate_indices=False)
- return tf.cast(tf.transpose(alignment_matrix), dtype)
+ return tf.transpose(alignment_matrix)
def guided_alignment_cost(attention_probs,
gold_alignment,
