def fetch_binarized_mnist():
    """ Get binarized version of MNIST data """
    train_set, valid_set, test_set = fetch_mnist()
    train_X = train_set[0]
    train_y = train_set[1]
    valid_X = valid_set[0]
    valid_y = valid_set[1]
    test_X = test_set[0]
    test_y = test_set[1]

    random_state = np.random.RandomState(1999)

    def get_sampled(arr):
        # make sure that a pixel can always be turned off
        return random_state.binomial(1, arr * 256. / 255, size=arr.shape)

    train_X = get_sampled(train_X)
    valid_X = get_sampled(valid_X)
    test_X = get_sampled(test_X)

    train_set = (train_X, train_y)
    valid_set = (valid_X, valid_y)
    test_set = (test_X, test_y)

    """
    # Old version for true binarized mnist
    data_path = check_fetch_binarized_mnist()
    fpath = os.path.join(data_path, "binarized_mnist.npz")

    arr = np.load(fpath)
    train_x = arr['train_data']
    valid_x = arr['valid_data']
    test_x = arr['test_data']
    train, valid, test = fetch_mnist()
    train_y = train[1]
    valid_y = valid[1]
    test_y = test[1]
    train_set = (train_x, train_y)
    valid_set = (valid_x, valid_y)
    test_set = (test_x, test_y)
    """
    return train_set, valid_set, test_set
dataset/ETHPy150Open kastnerkyle/SciPy2015/graphics_code/cvae/kdl_template.py/fetch_binarized_mnist/swapped operands of `/`