(n_samples_per_shape: int, n_points: int, noise: float)
return point_clouds, labels
Make point clouds for circles, spheres, and tori with random noise.
Make point clouds for circles, spheres, and tori with random noise.
Make point clouds for circles spheres and tori with random noise .
def make_point_clouds(n_samples_per_shape: int, n_points: int, noise: float):
    """Make point clouds for circles, spheres, and tori with random noise.
    """
    circle_point_clouds = [
        np.asarray(
            [
                [np.sin(t) + noise * (np.random.rand(1)[0] - 0.5), np.cos(t) + noise * (np.random.rand(1)[0] - 0.5), 0]
                for t in range((n_points ** 2))
            ]
        )
        for kk in range(n_samples_per_shape)
    ]
    # label circles with 0
    circle_labels = np.zeros(n_samples_per_shape)

    sphere_point_clouds = [
        np.asarray(
            [
                [
                    np.cos(s) * np.cos(t) + noise * (np.random.rand(1)[0] - 0.5),
                    np.cos(s) * np.sin(t) + noise * (np.random.rand(1)[0] - 0.5),
                    np.sin(s) + noise * (np.random.rand(1)[0] - 0.5),
                ]
                for t in range(n_points)
                for s in range(n_points)
            ]
        )
        for kk in range(n_samples_per_shape)
    ]
    # label spheres with 1
    sphere_labels = np.ones(n_samples_per_shape)

    torus_point_clouds = [
        np.asarray(
            [
                [
                    (2 + np.cos(s)) * np.cos(t) + noise * (np.random.rand(1)[0] - 0.5),
                    (2 + np.cos(s)) * np.sin(t) + noise * (np.random.rand(1)[0] - 0.5),
                    np.sin(s) + noise * (np.random.rand(1)[0] - 0.5),
                ]
                for t in range(n_points)
                for s in range(n_points)
            ]
        )
        for kk in range(n_samples_per_shape)
    ]
    # label tori with 2
    torus_labels = 2 * np.ones(n_samples_per_shape)

    point_clouds = np.concatenate((circle_point_clouds, sphere_point_clouds, torus_point_clouds))
    labels = np.concatenate((circle_labels, sphere_labels, torus_labels))

    return point_clouds, labels
def make_point_clouds ( n_samples_per_shape : int , n_points : int , noise : float ) : circle_point_clouds = [ np . asarray ( [ [ np . sin ( t ) + noise * ( np . random . rand ( 1 ) [ 0 ] - 0.5 ) , np . cos ( t ) + noise * ( np . random . rand ( 1 ) [ 0 ] - 0.5 ) , 0 ] for t in range ( ( n_points ** 2 ) ) ] ) for kk in range ( n_samples_per_shape ) ] # label circles with 0 circle_labels = np . zeros ( n_samples_per_shape ) sphere_point_clouds = [ np . asarray ( [ [ np . cos ( s ) * np . cos ( t ) + noise * ( np . random . rand ( 1 ) [ 0 ] - 0.5 ) , np . cos ( s ) * np . sin ( t ) + noise * ( np . random . rand ( 1 ) [ 0 ] - 0.5 ) , np . sin ( s ) + noise * ( np . random . rand ( 1 ) [ 0 ] - 0.5 ) , ] for t in range ( n_points ) for s in range ( n_points ) ] ) for kk in range ( n_samples_per_shape ) ] # label spheres with 1 sphere_labels = np . ones ( n_samples_per_shape ) torus_point_clouds = [ np . asarray ( [ [ ( 2 + np . cos ( s ) ) * np . cos ( t ) + noise * ( np . random . rand ( 1 ) [ 0 ] - 0.5 ) , ( 2 + np . cos ( s ) ) * np . sin ( t ) + noise * ( np . random . rand ( 1 ) [ 0 ] - 0.5 ) , np . sin ( s ) + noise * ( np . random . rand ( 1 ) [ 0 ] - 0.5 ) , ] for t in range ( n_points ) for s in range ( n_points ) ] ) for kk in range ( n_samples_per_shape ) ] # label tori with 2 torus_labels = 2 * np . ones ( n_samples_per_shape ) point_clouds = np . concatenate ( ( circle_point_clouds , sphere_point_clouds , torus_point_clouds ) ) labels = np . concatenate ( ( circle_labels , sphere_labels , torus_labels ) ) return point_clouds , labels