jacobian

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

commit df40d575343e8f46956b57f319ad16981a37e785
parent 359a7399eb9b18bd8f0a4786abf58a7754a3e569
Author: David Freifeld <freifeld.david@gmail.com>
Date:   Mon, 28 Sep 2020 12:11:03 -0700

Tweaks to buffer

Diffstat:
Msrc/bpnn.hpp | 2+-
Msrc/data.cpp | 13++++++-------
2 files changed, 7 insertions(+), 8 deletions(-)

diff --git a/src/bpnn.hpp b/src/bpnn.hpp @@ -46,7 +46,7 @@ public: int data; int val_data; int instances; - float buf[BUFFER_SIZE]; + std::byte buf[BUFFER_SIZE]; int val_instances; int test_instances; Eigen::MatrixXf numerical_grad(int i, float epsilon); diff --git a/src/data.cpp b/src/data.cpp @@ -40,22 +40,21 @@ int Network::next_batch(int fd) { Expects(fd > 0); // File descriptor must be valid. uintmax_t lines = 0; - read(fd, buf, 4); - printf("%x\n", *buf); while(size_t bytes_read = read(fd, buf, BUFFER_SIZE)) { + printf("hi\n"); if (!bytes_read) { printf("hit end of file\n"); break; } - for(float* p = buf; p < buf+BUFFER_SIZE;) { + 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), *p); - (*layers[0].contents)(lines,i) = *p; + 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", *p); - (*labels)(lines,0) = *p; + printf("%f\n", *(reinterpret_cast<float*>(p))); + (*labels)(lines,0) = *(reinterpret_cast<float*>(p)); p += sizeof(float); ++lines; }