implemented nnue load
This commit is contained in:
1 parent
82c969a2ad
commit
67e9ebdda3
6 files changed
+55
-6
No files matched your search
@@ -1,4 +1,6 @@
|
||||
#include <immintrin.h>
|
||||
#include <fstream>
|
||||
|
||||
#include "nnue.h"
|
||||
#include "accumulator.h"
|
||||
#include "board.h"
|
||||
@@ -6,6 +8,43 @@
|
||||
|
||||
namespace NNUE {
|
||||
|
||||
void Network::Load(const std::string& path) {
|
||||
std::ifstream file(path, std::ios::binary);
|
||||
if (!file.is_open()){
|
||||
std::cerr << "Failed to open file " + path << std::endl;
|
||||
}
|
||||
|
||||
// HL weights
|
||||
for (int i = 0; i < accumulator_weights.size(); i++) {
|
||||
file.read(reinterpret_cast<char*>(&accumulator_weights[i]), sizeof(int16_t));
|
||||
}
|
||||
|
||||
// HL biases
|
||||
for (int i = 0; i < accumulator_biases.size(); i++) {
|
||||
file.read(reinterpret_cast<char*>(&accumulator_biases[i]), sizeof(int16_t));
|
||||
}
|
||||
|
||||
// Output weights
|
||||
for (int i = 0; i < output_weights.size(); i++) {
|
||||
file.read(reinterpret_cast<char*>(&output_weights[i]), sizeof(int16_t));
|
||||
}
|
||||
|
||||
// Output bias
|
||||
file.read(reinterpret_cast<char*>(&output_bias), sizeof(int16_t));
|
||||
}
|
||||
|
||||
void Network::Print() {
|
||||
std::cout << "First 16 HL biases: ";
|
||||
|
||||
for (int i = 0; i < 16; i++) {
|
||||
std::cout << accumulator_biases[i] << ' ';
|
||||
}
|
||||
|
||||
std::cout << std::endl;
|
||||
|
||||
std::cout << "Output neuron bias: " << output_bias << std::endl;
|
||||
}
|
||||
|
||||
static int32_t Forward(const Board& board,
|
||||
const Network* net) {
|
||||
const ACC::Accumulator& stmAcc = board.sideToMove == White ? board.accPair.white : board.accPair.black;
|
||||
|
||||
Reference in new issue
Block a user