Skip to content

Commit

Permalink
lil fix but improvements are comming
Browse files Browse the repository at this point in the history
  • Loading branch information
Eliyaan committed Mar 10, 2023
1 parent 8bc1391 commit 00ea715
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
1 change: 0 additions & 1 deletion other_file.v
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,4 @@ fn main(){
neunet.init()
neunet.train(u64(nb_epochs))
}
neunet.init()
}
9 changes: 6 additions & 3 deletions preceptron/preceptron.v
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ pub struct NeuralNet{

save_path string
load_path string
print bool

mut:
weights_list [][][][]f64
Expand Down Expand Up @@ -249,7 +250,7 @@ fn (mut nn NeuralNet) randomise_i_exp_o(){

pub fn (mut nn NeuralNet) init(){
if nn.load_path != ""{
file := toml.parse_file(nn.save_path) or {panic(err)}
file := toml.parse_file(nn.load_path) or {panic(err)}
nn.best_cost = file.value("cost").f64()
base_weights_list := file.value("weights").array()
base_layers_list := file.value("layers").array()
Expand Down Expand Up @@ -373,7 +374,7 @@ pub fn (mut nn NeuralNet) train(nb_epochs u64){
nn.backprop(i)
nn.glob_output[i] = nn.layers_list[nn.nb_hidden_layer][3]
}
if nn.print_epoch > 0{
if nn.print_epoch > 0 && nn.print{
if epoch%u64(nn.print_epoch) == 0{
println('\nEpoch: $epoch Global Cost: ${nn.global_cost} \nOutputs: $nn.glob_output \nExpected Outputs: $nn.excpd_outputs')
}
Expand All @@ -386,7 +387,9 @@ pub fn (mut nn NeuralNet) train(nb_epochs u64){
nn.best_cost = nn.global_cost
}
}
println('____________________________________________________________\nFinal Results: \nCost: ${nn.global_cost} \nOutputs: $nn.glob_output \nExpected Outputs: $nn.excpd_outputs')
if nn.print{
println('____________________________________________________________\nFinal Results: \nCost: ${nn.global_cost} \nOutputs: $nn.glob_output \nExpected Outputs: $nn.excpd_outputs')
}
if need_to_save{
file := "cost=${cost_to_save}\nweights=${weights_to_save}\nlayers=${layers_to_save}"
os.write_file(nn.save_path, file) or {panic(err)}
Expand Down

0 comments on commit 00ea715

Please sign in to comment.