You will need a so called dataset this is a big collection of training examples with correct answers. Also you will need a validation/testing dataset, this will be used to test the network accuracy.
In the code we provide two dataset options:
- MNIST 28x28 number recoginition
- MNIST 28x28 fashion items recognition
But feel free to add your own, just use *ONE HOT ENCODING for the lables/answers.
Create a variable that your network will be saved in.
Arguments:
- A list on the layer sizes starting from the first hidden layer
- A list of activation functions in strings
- An INT of how many inputs are there
my_network = Network([32, 16, 10], ["sigmoid", "relu", "softmax"], 784)
Activation functions options:
- "relu"
- "sigmoid"
- "softmax"
- None
You could train the network with the learn method, but this is not very efficient, instead use the learn_adaptive_lr method, this changes the learning rate during training, so you get better and faster results.
Arguments:
- Your training dataset
- Your training labels/answers
- Your testing dataset
- Your testing labels/answers
- Batch size
- String for your model name, if it is set to
"current", then no network will be loaded. (The .nzp will be added automaticly) - Your loss function
- The derivate of your loss function
- How many generations
- Make the number higher if the learning rate stalls and the success is not optimal. If it rolls back lowwer this number.
- How many generations will it look to determine the learning rate
my_network.learn_adaptive_lr(
train_images,
train_labels,
test_images,
test_labels,
32,
"current",
"ce",
num_gens= 10,
lr_slope= 1.5,
moving_avg_num= 4
)