GithubHelp home page GithubHelp logo

leela-chess's People

Contributors

benediamond avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

leela-chess's Issues

Write the move_lookup map

static std::unordered_map<Move, int> move_lookup;

The dictionary defined here will be used during the MCTS search, to use Moves to index into the Network's results, i.e. in:

leela-chess/src/UCTNode.cpp

Lines 116 to 120 in 3079185

for (Move move : moves) {
auto node = raw_netlist.first[UCTSearch::move_lookup[move]];
nodelist.emplace_back(node.first, move);
legal_sum += node.first;
}

I've already done something like this in my Python repository, see https://github.com/benediamond/chess-alpha-zero/blob/588b4d4f81978805be6a178faf8469948d891721/src/chess_zero/config.py#L19-L86

Integrating UCTSearch with scripts

Though the UCTSearch and UCTNode classes should be all but functional as is (except for adapting the Network, see Issue #1) I haven't integrated these with the scripts handling the command line interface and autogp and so on. As it stands, I have just dumped into main.cpp the beginnings of how to set everything up:

leela-chess/src/main.cpp

Lines 54 to 59 in c92efdb

Position game;
StateListPtr states(new std::deque<StateInfo>(1));
game.set(StartFEN, &states->back());
auto search = std::make_unique<UCTSearch>(game, states);
search->think();

But this should be handled by a smoother utility that orchestrates games of self-play, etc. (presumably this code is already written). Note: once this is done, the moves encountered should be properly emplace_backed onto states, as in stockfish:

https://github.com/official-stockfish/Stockfish/blob/2198cd0524574f0d9df8c0ec9aaf14ad8c94402b/src/uci.cpp#L69-L78

Adapting Network and OpenCL

The get_scored_moves_internal routine of Network.cpp, together with the entirety of OpenCL.cpp, are littered with constants specific to Go (19, 391, 392, etc.). Presumably, this is just a matter of changing a few numbers. Yet the whole thing is fairly complicated, so I have held off on doing this for the time being. Here are a few examples:

leela-chess/src/Network.cpp

Lines 356 to 360 in 8675bd2

Network::Netresult Network::get_scored_moves_internal(Position* pos, NNPlanes& planes) { //--must fix this!
assert(INPUT_CHANNELS == planes.size());
constexpr int width = 19;
constexpr int height = 19;
const auto convolve_channels = conv_pol_w.size() / conv_pol_b.size();

leela-chess/src/Network.cpp

Lines 383 to 393 in 8675bd2

convolve<1, 2>(output_data, conv_pol_w, conv_pol_b, policy_data_1);
batchnorm<2, 361>(policy_data_1, bn_pol_w1, bn_pol_w2, policy_data_2);
innerproduct<2*361, 362>(policy_data_2, ip_pol_w, ip_pol_b, policy_out);
softmax(policy_out, softmax_data, cfg_softmax_temp);
std::vector<float>& outputs = softmax_data;
// Now get the score
convolve<1, 1>(output_data, conv_val_w, conv_val_b, value_data_1);
batchnorm<1, 361>(value_data_1, bn_val_w1, bn_val_w2, value_data_2);
innerproduct<361, 256>(value_data_2, ip1_val_w, ip1_val_b, winrate_data);
innerproduct<256, 1>(winrate_data, ip2_val_w, ip2_val_b, winrate_out);

leela-chess/src/OpenCL.cpp

Lines 559 to 572 in 3079185

size_t stripSize;
int rowTileSize;
int rowTiles;
if (filter_size == 3) {
stripSize = filter_size * (width + (filter_size - 1)) * sizeof(float);
rowTiles = cfg_rowtiles;
rowTileSize = (19 + rowTiles - 1) / rowTiles;
} else {
assert(filter_size == 1);
stripSize = width * sizeof(float);
rowTiles = 19;
rowTileSize = 1;
assert(channelGroup == 8); // hardcoded in kernel
}

Supervised learning

Hi, @benediamond. I like this approximation very much. I'll try to help in my possibilities.

I don't know yet the source code of this project too much but I think we should implement a supervised learning script able to create input files for checking the model is able to converge.

I thought about importing directly the python script we already have in order just to create the input files for feeding the model. How do we need to create this files? what's its format?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.