niteshade.utils

General utility and helper functions.

Functions

check_batch_size(y)

Check the batch size of input label data.

check_num_of_classes(y)

Check the number of classes in one hot encoded data.

copy(array_like)

Used to copy a torch.Tensor or np.ndarray object.

decode_one_hot(y)

Decode one hot encoded data.

get_cmap(nlabels)

get_time_stamp_as_string()

Get the current time stamp as a string.

load_model(filename)

Load a binary file containing a neural network.

one_hot_encoding(y, num_classes)

Perform one hot encoding of previiously decoded data.

rand_cmap(nlabels)

Creates a random colormap to be used together with matplotlib.

save_model(model, filename)

Save an object as a binary .pickle file.

save_pickle(results[, dirname, filename])

Save results as a .pickle file.

save_plot(plt[, dirname, plotname])

Save a matplotlib.pyplot.plot() as a .png file.

train_test_MNIST([dir, transform, val_size])

Function to load torchivisions' MNIST dataset, splitted into train, test, and validation sets (the latter only if val_size != None).

train_test_cifar([dir, transform, val_size])

Function to load torchvisions' CIFAR10 dataset, splitted into train, test, and validation sets (the latter only if val_size != None).

train_test_iris([test_size, val_size, ...])

Loads the Iris dataset using sklearn.datasets.load_iris() and returns the inputs and labels in splitted train and test sets (and validation too if val_size != None).