def restore_pad(x, ref_x, pad_remover, mode): x = tf.squeeze(x, axis=0) if mode != ModeKeys.PREDICT: x = pad_remover.restore(x) x = expert_utils.reshape_like(x, ref_x) return x
def restore_pad(x, ref_x, pad_remover, mode): x = tf.squeeze(x, axis=0) if mode != ModeKeys.PREDICT: x = pad_remover.restore(x) x = expert_utils.reshape_like(x, ref_x) return x
def tpu_gather(params, indices): vocab_size = params.get_shape().as_list()[0] indices_flat = tf.reshape(indices, [-1]) out = tf.matmul(tf.one_hot(indices_flat, vocab_size), params) out = eu.reshape_like(out, tf.expand_dims(indices, -1)) return out
def tpu_gather(params, indices): vocab_size = params.get_shape().as_list()[0] indices_flat = tf.reshape(indices, [-1]) out = tf.matmul(tf.one_hot(indices_flat, vocab_size), params) out = eu.reshape_like(out, tf.expand_dims(indices, -1)) return out