package neural_nets_lib

  1. Overview
  2. Docs

Module Datasets.Half_moonsSource

Half moons synthetic dataset generation

Sourcemodule Config : sig ... end

Configuration for the half moons dataset

Sourceval generate_with_kind : (float, 'a) Stdlib__Bigarray.kind -> ?config:Config.t -> len:int -> unit -> (float, 'a, Bigarray.c_layout) Bigarray.Genarray.t * (float, 'a, Bigarray.c_layout) Bigarray.Genarray.t

Internal helper function to generate half moons with specified precision.

  • parameter kind

    The bigarray kind (float32 or float64)

  • parameter config

    Configuration for noise and randomization

  • parameter len

    Number of samples per moon (total samples = len * 2)

  • returns

    A tuple of (coordinates, labels) where:

    • coordinates is a bigarray of shape len*2; 2 (batch_axis, output_axis)
    • labels is a bigarray of shape len*2; 1 (batch_axis, output_axis)
    • First moon has label 1.0, second moon has label -1.0

Generate the half moons dataset with the specified parameters.

  • parameter config

    Configuration for noise and randomization

  • parameter len

    Number of samples per moon (total samples = len * 2)

  • returns

    A tuple of (coordinates, labels) where:

    • coordinates is a bigarray of shape len*2; 2 (batch_axis, output_axis)
    • labels is a bigarray of shape len*2; 1 (batch_axis, output_axis)
    • First moon has label 1.0, second moon has label -1.0
Sourceval generate_single_prec : ?config:Config.t -> len:int -> unit -> (float, Bigarray.float32_elt, Bigarray.c_layout) Bigarray.Genarray.t * (float, Bigarray.float32_elt, Bigarray.c_layout) Bigarray.Genarray.t

Generate the half moons dataset with single precision floats.

  • parameter config

    Configuration for noise and randomization

  • parameter len

    Number of samples per moon (total samples = len * 2)

  • returns

    A tuple of (coordinates, labels) where:

    • coordinates is a bigarray of shape len*2; 2 (batch_axis, output_axis) with float32 elements
    • labels is a bigarray of shape len*2; 1 (batch_axis, output_axis) with float32 elements
    • First moon has label 1.0, second moon has label -1.0
Sourceval generate_arrays : ?noise_range:float -> len:int -> unit -> float array * float array

Generate half moons dataset using the old array-based approach for compatibility. This function is deprecated and provided for backwards compatibility.

  • parameter len

    Number of samples per moon

  • parameter noise_range

    Range of noise to add

  • returns

    A tuple of (coordinates_array, labels_array) as flat arrays

OCaml

Innovation. Community. Security.