Datasets
data_generators
generate_linear_data(m, b, n_samples, xmin=0, xmax=10, noise_scale=2)
Generates x and y coordinates that can be fitted to a linear model
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
m
|
float
|
Slope of the linear model that generates the data. |
required |
b
|
float
|
Bias of the linear model that generates the data. |
required |
n_samples
|
int
|
Number of data points to generate. |
required |
xmin
|
int
|
Minimum X coordinate of the generated data. |
0
|
xmax
|
int
|
Maximum X coordinate of the generated data. |
10
|
noise_scale
|
float
|
Scale of the random noise. |
2
|
Returns:
| Type | Description |
|---|---|
tuple[ndarray, ndarray]
|
tuple[np.ndarray, np.ndarray]: X and Y data. |
Source code in src/nnfs/datasets/data_generators.py
generate_XOR_gate()
Generates x and y coordinates representing a XOR gate.
This is a classic example of a problem that cannot be solved by a single linear neuron.
Returns:
| Type | Description |
|---|---|
tuple[ndarray, ndarray]
|
tuple[np.ndarray, np.ndarray]: X and Y data. |
Source code in src/nnfs/datasets/data_generators.py
generate_two_moons(n_samples)
Generates x and y coordinates that represent two partially complementary half-moons.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n_samples
|
int
|
Number of data points to generate. |
required |
Returns:
| Type | Description |
|---|---|
tuple[ndarray, ndarray]
|
tuple[np.ndarray, np.ndarray]: X and Y data. |
Source code in src/nnfs/datasets/data_generators.py
generate_concentric_circles(n_samples, n_circles, binary=False)
Generates x and y coordinates that represent concentric circles.
By default, each circle has its own category (y), which increases with the radius.
Can be made into a binary classification dataset with the binary flag.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n_samples
|
int
|
Number of data points to generate. |
required |
n_circles
|
int
|
Number of circles to generate. |
required |
binary
|
bool
|
Whether to generate alternating binary categories. |
False
|
Returns:
| Type | Description |
|---|---|
tuple[ndarray, ndarray]
|
tuple[np.ndarray, np.ndarray]: X and Y data. |
Source code in src/nnfs/datasets/data_generators.py
data_loaders
load_mnist(use_cached=True)
Load the MNIST digit dataset.
It consists of 70000 images of handwritten digits (28x28 pixels, flattened), and their numeric labels.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
use_cached
|
bool
|
Whether to use pre-cached content or not. |
True
|
Returns:
| Type | Description |
|---|---|
tuple[ndarray, ndarray]
|
tuple[np.ndarray, np.ndarray]: X and Y data. |