# Step 3: train the teacher, a bigger network that learns the answers.
from tiny_nn import Random, load_windows, split, new_layer, train, accuracy, count, save

xs, ys = load_windows("windows.csv")
train_x, train_y, test_x, test_y = split(xs, ys)

rng = Random(42)
teacher = [new_layer(4, 8, rng), new_layer(8, 3, rng)]

# The right answer gets 1, the others 0.
answers = [[1.0 if k == y else 0.0 for k in range(3)] for y in train_y]

print(f"Training the teacher on {len(train_x)} windows: 4 inputs, 8 hidden, 3 outputs")
train(teacher, train_x, answers, epochs=1000, rate=0.5)
print(f"Teacher got {accuracy(teacher, test_x, test_y)} of {len(test_y)} test windows right")

save(teacher, "teacher.txt")
print(f"Saved its {count(teacher)} numbers to teacher.txt")
