Last active
April 20, 2024 16:17
-
-
Save masterdezign/4f09e4444d0330e2984c2e11c593386e to your computer and use it in GitHub Desktop.
Revisions
-
masterdezign revised this gist
Apr 20, 2024 . 1 changed file with 10 additions and 7 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,20 +1,23 @@ import numpy as np def spirals(n_samples=400): N = n_samples theta = np.sqrt(np.random.rand(N))*2*np.pi r_a = 2*theta + np.pi data_a = np.array([np.cos(theta)*r_a, np.sin(theta)*r_a]).T x_a = data_a + np.random.randn(N,2) r_b = -2*theta - np.pi data_b = np.array([np.cos(theta)*r_b, np.sin(theta)*r_b]).T x_b = data_b + np.random.randn(N,2) res_a = np.zeros((N,1), dtype='uint8') res_b = np.ones((N,1), dtype='uint8') x = np.concatenate([x_a, x_b], axis=0) res = np.concatenate([res_a, res_b], axis=0).reshape(-1) return x, res Xdata, ydata = spirals() -
masterdezign created this gist
Apr 20, 2024 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,20 @@ def spirals(n_samples=400): N = n_samples theta = np.sqrt(np.random.rand(N))*2*pi # np.linspace(0,2*pi,100) r_a = 2*theta + pi data_a = np.array([np.cos(theta)*r_a, np.sin(theta)*r_a]).T x_a = data_a + np.random.randn(N,2) r_b = -2*theta - pi data_b = np.array([np.cos(theta)*r_b, np.sin(theta)*r_b]).T x_b = data_b + np.random.randn(N,2) res_a = np.zeros((N,1), dtype='uint8') res_b = np.ones((N,1), dtype='uint8') x = np.concatenate([x_a, x_b], axis=0) res = np.concatenate([res_a, res_b], axis=0).reshape(-1) return x, res Xdata, ydata = spirals()