def repeat_elements(x, rep, axis):
    x_shape = x.get_shape().as_list()
    # slices along the repeat axis
    splits = tf.split(axis, x_shape[axis], x)
    # repeat each slice the given number of reps
    x_rep = [s for s in splits for i in range(rep)]
    return tf.concat(axis, x_rep)
Repeats the elements of a tensor along an axis, like np.repeat
dataset/ETHPy150Open fchollet/keras/keras/backend/tensorflow_backend.py/repeat_elements