Skip to content

Commit

Permalink
Fixes ?
Browse files Browse the repository at this point in the history
  • Loading branch information
Panjaksli committed Aug 31, 2023
1 parent f92dc07 commit 00a82de
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
7 changes: 4 additions & 3 deletions BNN/NNet/NNet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ namespace BNN {
println("Failed training the network !!!");
return false;
}
cost *= mult;
net.Zero();
for(const auto& n : nets) {
for(idx i = 1; i < net.graph.size() - 1; i++) {
Expand All @@ -131,10 +132,10 @@ namespace BNN {
if(net.optimizer->get_mb(i)) *net.optimizer->get_mb(i) += mult * (*n.optimizer->get_mb(i));
}
}
printr("Step:", step + 1, "Cost:", cost * mult, "Time:", timer(t), " ");
best_cost = fminf(cost, best_cost);
printr("Step:", step + 1, "Cost:", cost, "Time:", timer(t), " ");
}
best_cost = fminf(cost * mult, best_cost);
println("Trained Network:", name, "Cost:", cost * mult, "Best:", best_cost, "Time:", timer(t), " ");
println("Trained Network:", name, "Cost:", cost, "Best:", best_cost, "Time:", timer(t), " ");
*this = net;
return true;
}
Expand Down
6 changes: 3 additions & 3 deletions Example1/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ using namespace BNN;

//rgb upscaling
int main() {
#if 0
#if 1
//Inference code
NNet net("Upscaling_net");
std::string inp, outp;
Expand All @@ -21,7 +21,7 @@ int main() {
y.chip(i, 0) = net.Compute_DS(x.chip(i, 0).reshape(dim1<3>{1, x.dimension(1), x.dimension(2)})).chip(i, 0);
Image(y).save(outp + ".png");*/
//DIFF MODEL
Tensor x = Image(inp, 3, 1).tensor_rgb();
Tensor x = Image(inp, 3, 1).tensor_rgb(true);
Image(net.Compute_DS(x) + resize(x, 2, 2)).save(outp + ".png");
//Cubic
//Image(inp, 3, 1).resize_cubic(960,720).save(outp + ".png");
Expand All @@ -33,7 +33,7 @@ int main() {
std::string parent = "Upscaler/";
//Input data
std::string in_folder = "Downscaler/";
std::string netname = parent + "ups_c5x32_c3x32x3_c3_ps2_dy_cu";
std::string netname = parent + "ups_c5x32_c3x32x2_c3_ps2_dy_cu";
Tenarr x(3, 240, 160, train_set);
#pragma omp parallel for
for(idx i = 0; i < train_set; i++)
Expand Down

0 comments on commit 00a82de

Please sign in to comment.