def test_img1(): for n_features in [10, 20, 50]: img = datasets.load_img1(n_features, 20) assert img.shape[0] == n_features assert img.shape[1] == 20
colors = ['#7fc97f', '#beaed4', '#fdc086'] from copt.total_variation import prox_tv2d, prox_tv1d_rows, prox_tv1d_cols from copt import three_split, proximal_gradient from copt.utils import Trace from copt.datasets import load_img1 from scipy import misc ############################################################### # Load an ground truth image and generate the dataset (A, b) as # # b = A ground_truth + noise , # # where A is a random matrix. We will now load the ground truth image img = load_img1() n_rows, n_cols = img.shape n_features = n_rows * n_cols np.random.seed(0) n_samples = n_features # set L2 regularization (arbitrarily) to 1/n_samples l2_reg = 1.0 / n_samples A = np.random.uniform(-1, 1, size=(n_samples, n_features)) for i in range(A.shape[0]): A[i] /= linalg.norm(A[i]) b = A.dot(img.ravel()) + 1.0 * np.random.randn(n_samples)