Auxiliary Functions¶
Here are the auxiliary functions that are used in the rest of the programs. These functions can be divided in three groups:
A function for dividing the data in batches.
Some functions for evaluation predicted values returned by the network.
Functions to load data (fashion and mnist).
-
deatf.auxiliary_functions.batch(data, n, i)¶ Extract from the given data a batch that go from the position i to the i + n; being n the batch size .
- Parameters
data – Set of solutions intended to be fed to the network.
n – Size of the desired batch.
i – Index of the last solution used in the last epoch.
- Returns
The batch of data form x with size n since the index i of the data.
-
deatf.auxiliary_functions.mse(true, prediction)¶ Calculates the mean squared error with numpy functions.
- Parameters
true – True data, is the ground of truth in the evaluation.
prediction – Predicted data, is the data that is evaluated.
- Returns
The mean squared error calculated between the true and predicted data.
-
deatf.auxiliary_functions.accuracy_error(true, prediction)¶ Calculates the accuracy error with numpy functions.
- Parameters
true – True data, is the ground of truth in the evaluation.
prediction – Predicted data, is the data that is evaluated.
- Returns
The accuracy error calculated between the true and predicted data.
-
deatf.auxiliary_functions.balanced_accuracy(true, prediction)¶ Calculates the balanced accuracy with numpy functions.
- Parameters
true – True data, is the ground of truth in the evaluation.
prediction – Predicted data, is the data that is evaluated.
- Returns
The balaced accuracy error calculated between the true and predicted data.
-
deatf.auxiliary_functions.load_fashion()¶ Loads and returns the data from the fashion mnist dataset and is returned already divided in train, validation and test.
- Returns
Data of fashion mnist dataset divided in train, test and validation (x_train, y_train, x_test, y_test, x_val, y_val).
- Rtype x_train
uint8 NumPy array of grayscale image data with shapes (42000, 28, 28), containing the training data.
- Rtype y_train
uint8 NumPy array of labels (integers in range 0-9) with shape (42000,) for the training data.
- Rtype x_test
uint8 NumPy array of grayscale image data with shapes (10000, 28, 28), containing the test data.
- Rtype y_test
uint8 NumPy array of labels (integers in range 0-9) with shape (10000,) for the test data.
- Rtype x_val
uint8 NumPy array of grayscale image data with shapes (18000, 28, 28), containing the validation data.
- Rtype y_val
uint8 NumPy array of labels (integers in range 0-9) with shape (18000,) for the validation data.
-
deatf.auxiliary_functions.load_mnist()¶ Loads and returns the data from the mnist dataset and is returned already divided in train, validation and test.
- Returns
Data of mnist dataset divided in train, test and validation (x_train, y_train, x_test, y_test, x_val, y_val).
- Rtype x_train
uint8 NumPy array of grayscale image data with shapes (42000, 28, 28), containing the training data. Pixel values range from 0 to 255.
- Rtype y_train
uint8 NumPy array of labels (integers in range 0-9) with shape (42000,) for the training data.
- Rtype x_test
uint8 NumPy array of grayscale image data with shapes (10000, 28, 28), containing the test data. Pixel values range from 0 to 255.
- Rtype y_test
uint8 NumPy array of labels (integers in range 0-9) with shape (10000,) for the test data.
- Rtype x_val
uint8 NumPy array of grayscale image data with shapes (18000, 28, 28), containing the validation data. Pixel values range from 0 to 255.
- Rtype y_val
uint8 NumPy array of labels (integers in range 0-9) with shape (18000,) for the validation data.