-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontroller.jl
51 lines (41 loc) · 1.55 KB
/
controller.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
include("network.jl")
include("input.jl")
include("weights.jl")
include("activation.jl")
global input_neurons = length(get_inputs("train")[1])
global hidden_neurons = 75
global output_neurons = 10
global weight_l_rate = 0.2
global bias_l_rate = 0.1
#runs training on all inputs of dataset
function run_training()
init()
parameters = [load("data/hidden_weights.jld"), load("data/output_weights.jld"), load("data/hidden_biases.jld"), load("data/output_biases.jld")]
inputs = get_inputs("train")
targets = get_targets("train")
println("Running training...")
println("")
for i = 1 : length(inputs)
parameters = train(inputs[i], [parameters[1], parameters[2]], [parameters[3], parameters[4]], targets[i])
end
println("Done!")
save(parameters[1], "data/hidden_weights.jld")
save(parameters[2], "data/output_weights.jld")
save(parameters[3], "data/hidden_biases.jld")
save(parameters[4], "data/output_biases.jld")
end
#tests the network on the entire test set
function benchmark()
parameters = [load("data/hidden_weights.jld"), load("data/output_weights.jld"), load("data/hidden_biases.jld"), load("data/output_biases.jld")]
inputs = get_inputs("test")
targets = get_targets("test")
correct = 0
events = length(inputs)
println("Benchmarking...")
println("")
for i = 1 : events
correct += test(inputs[i], [parameters[1], parameters[2]], [parameters[3], parameters[4]], targets[i])
end
print("Accuracy: ")
println(string(round((correct / events) * 100, digits=2)) * "%")
end