def _check_dimension(y_true, y_pred):
    """Check if the dimension of true target and predicted target match."""
    # if 1D, reshape as 2D
    if y_true.ndim == 1:
        y_true = y_true.reshape((-1, 1))
    if y_pred.ndim == 1:
        y_pred = y_pred.reshape((-1, 1))

    # check the number of samples
    if y_true.shape[0] != y_pred.shape[0]:
        raise ValueError("Number of samples does not correspond: ",
                         "y_true has {}, y_pred has {}.".format(y_true.shape[0], y_pred.shape[0]))

    # check the number of output
    if y_true.shape[1] != y_pred.shape[1]:
        raise ValueError("Number of output does not correspond: ",
                         "y_true has {}, y_pred has {}.".format(y_true.shape[1], y_pred.shape[1]))

    return y_true, y_pred