MCPcopy Create free account
hub / github.com/OpenPTrack/open_ptrack_v2 / load_go

Function load_go

yolo_detector/darknet_opt/src/data.c:1419–1463  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1417}
1418
1419data load_go(char *filename)
1420{
1421 FILE *fp = fopen(filename, "rb");
1422 matrix X = make_matrix(3363059, 361);
1423 matrix y = make_matrix(3363059, 361);
1424 int row, col;
1425
1426 if(!fp) file_error(filename);
1427 char *label;
1428 int count = 0;
1429 while((label = fgetl(fp))){
1430 int i;
1431 if(count == X.rows){
1432 X = resize_matrix(X, count*2);
1433 y = resize_matrix(y, count*2);
1434 }
1435 sscanf(label, "%d %d", &row, &col);
1436 char *board = fgetl(fp);
1437
1438 int index = row*19 + col;
1439 y.vals[count][index] = 1;
1440
1441 for(i = 0; i < 19*19; ++i){
1442 float val = 0;
1443 if(board[i] == '1') val = 1;
1444 else if(board[i] == '2') val = -1;
1445 X.vals[count][i] = val;
1446 }
1447 ++count;
1448 free(label);
1449 free(board);
1450 }
1451 X = resize_matrix(X, count);
1452 y = resize_matrix(y, count);
1453
1454 data d = {0};
1455 d.shallow = 0;
1456 d.X = X;
1457 d.y = y;
1458
1459
1460 fclose(fp);
1461
1462 return d;
1463}
1464
1465
1466void randomize_data(data d)

Callers

nothing calls this directly

Calls 4

make_matrixFunction · 0.85
file_errorFunction · 0.85
fgetlFunction · 0.85
resize_matrixFunction · 0.85

Tested by

no test coverage detected