Skip to content

Commit

Permalink
Fixed fread() for net->seen
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexeyAB committed Oct 21, 2017
1 parent f18a82b commit db1d98d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
11 changes: 9 additions & 2 deletions src/additionally.c
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,7 @@ network make_network(int n)
network net = {0};
net.n = n;
net.layers = calloc(net.n, sizeof(layer));
net.seen = calloc(1, sizeof(int));
net.seen = calloc(1, sizeof(uint64_t));
#ifdef GPU
net.input_gpu = calloc(1, sizeof(float *));
net.truth_gpu = calloc(1, sizeof(float *));
Expand Down Expand Up @@ -1706,7 +1706,14 @@ void load_weights_upto_cpu(network *net, char *filename, int cutoff)
fread(&major, sizeof(int), 1, fp);
fread(&minor, sizeof(int), 1, fp);
fread(&revision, sizeof(int), 1, fp);
fread(net->seen, sizeof(int), 1, fp);
if ((major * 10 + minor) >= 2) {
fread(net->seen, sizeof(uint64_t), 1, fp);
}
else {
int iseen = 0;
fread(&iseen, sizeof(int), 1, fp);
*net->seen = iseen;
}
//int transpose = (major > 1000) || (minor > 1000);

int i;
Expand Down
3 changes: 2 additions & 1 deletion src/additionally.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <string.h>
#include <float.h>
#include <limits.h>
#include <stdint.h>

#ifdef CUDNN
#include "cudnn.h"
Expand Down Expand Up @@ -493,7 +494,7 @@ typedef struct network {
float *workspace;
int n;
int batch;
int *seen;
uint64_t *seen;
float epoch;
int subdivisions;
float momentum;
Expand Down

0 comments on commit db1d98d

Please sign in to comment.