commit 9f72f0065cbedbbc4ecc7351b20bc2137cfeaf8a
parent 28f23c2f297aad0abb3eeaec6e787d11bfb2a5a4
Author: David Freifeld <freifeld.david@gmail.com>
Date: Sun, 11 Oct 2020 11:38:26 -0700
Fixed some of program-breaking bug
Diffstat:
2 files changed, 2 insertions(+), 9 deletions(-)
diff --git a/src/bpnn.cpp b/src/bpnn.cpp
@@ -355,7 +355,6 @@ float Network::validate(char* path)
float costsum = 0;
float accsum = 0;
for (int i = 0; i <= val_instances-batch_size; i+=batch_size) {
- printf("callin next batch from validate\n");
next_batch(val_data);
feedforward();
costsum += cost();
@@ -373,10 +372,7 @@ void Network::train()
float acc_sum = 0;
for (int i = 0; i <= instances-batch_size; i+=batch_size) {
if (early_stop == true && get_val_cost() < threshold) return;
- if (i != instances-batch_size) {
- printf("callin nex batch from train\n");
- next_batch(data);
- }
+ if (i != instances-batch_size) next_batch(data);
feedforward();
backpropagate();
cost_sum += cost();
diff --git a/src/data.cpp b/src/data.cpp
@@ -34,6 +34,7 @@ void prep(char* rname, char* wname)
p = bound + 1;
}
}
+ fclose(wptr);
}
int Network::next_batch(int fd)
@@ -41,19 +42,15 @@ int Network::next_batch(int fd)
Expects(fd > 0); // File descriptor must be valid.
uintmax_t lines = 0;
while(size_t bytes_read = read(fd, buf, BUFFER_SIZE)) {
- printf("hi\n");
if (!bytes_read) {
- printf("hit end of file\n");
break;
}
for(std::byte* p = buf; p < buf+BUFFER_SIZE;) {
if (lines >= 10) return 0;
for (int i=0; i<layers[0].contents->cols(); ++i) {
- printf("%llx %f\n", *((int*)p), *(reinterpret_cast<float*>(p)));
(*layers[0].contents)(lines,i) = *(reinterpret_cast<float*>(p));
p += sizeof(float);
}
- printf("%f\n", *(reinterpret_cast<float*>(p)));
(*labels)(lines,0) = *(reinterpret_cast<float*>(p));
p += sizeof(float);
++lines;