Comments (5)
It would be messy to duplicate a new model file for every different possible model and have many versions of the code floating around that could then get out of sync with each other, so no this is not happening.
Perhaps the problem is not model_pytorch.py, but rather that you might not know how to look at the model file? You can see the full config for the model if you download a model file and load it in pytorch and look at the config:
data = torch.load(model_path,map_location="cpu")
print(data["config"])
The config contains a list of all the blocks in the model, in order, as well as the channel parameters and other settings. Every listed block in the model, like "bottlenest2", corresponds exactly to 1 "structure" in model_pytorch.py, which you can find if you search for that string in the code. So that should solve the problem with there being "various kinds of structures" - the config will let you determine precisely which ones are used. You can also iterate through the list of all the tensors in data["model"] to print their key and their shape, and see exactly the parameters.
from katago.
I'm trying to use b18c384nbt in my own python go_game. But i don't know what's the input of model. I first think it's same as AZ. But then i found it's total different. katago has two inputs, input_spatial and input_global. Is there a guide or example or something about the inputs?
from katago.
If you are simply trying to run KataGo from python because you want its suggested moves or analysis or ownership predictions, I recommend you ignore all of these details about the models and inputs and architectures. Just use query C++ analysis engine through subprocess:
Here is example code for doing that:
https://github.com/lightvector/KataGo/blob/master/python/query_analysis_engine_example.py
from katago.
I'm not just simply run KataGo from python. I want continue train model in python, use a different envs and MCTS. So i need to know the input of the model.
from katago.
Okay cool. In that case, take a look at https://github.com/lightvector/KataGo/blob/master/python/play.py - this is working code to load a neural net from python and query it based on a board position. It uses sgfmill for the board, and implements a basic GTP interface (https://www.lysator.liu.se/~gunnar/gtp/gtp2-spec-draft2/gtp2-spec.html) that will let you play on the command line with the bot which makes moves using the raw neural net (no MCTS).
The query to the neural net happens with the get_outputs
function, where gs
is a GameState
(class defined right above that). The reason for having two different input tensors is that one holds spatial features (like where the stones are), and one holds global features that don't depend on the board position (like what the rules and komi are). These are computed by features.fill_row_features
.
This is sort of old sandbox code that is mostly written a long time ago, so it's not very well commented or documented, so you'll have to do some work to trace the source code, but this should show you from start to end what the inference side of loading and running the net might look like purely from python.
Note that KataGo has no python MCTS implementation, so you're on your own there. This script only queries the raw net to make moves via the policy head directly. A lot of the graphical commands you see are designed for GoGUI, which is a particular gui you can try, which can view various outputs with graphical colors when this script is configured as the GTP engine for the gui.
from katago.
Related Issues (20)
- Why does lc0 ship cuda dlls with engine but katago doesn't?
- Minor document questions
- Error checks for kata-raw-human-nn HOT 1
- How to set rules to "twisted cross and eating" for beginner HOT 2
- Throwback HOT 3
- Lack of ability HOT 3
- Katago cannot give a definitive answer for the best move. HOT 2
- Report an error HOT 3
- allowResignation affects humanSL strength?? HOT 4
- Loose ladder
- katago 1.15.1 build failure HOT 1
- Do you have a plan to create a GUI? HOT 4
- kata-analyze reports a non-human-like move for the preaz_20k human profile HOT 1
- Evaluate the value of moves HOT 2
- KataGo works with old libssl versions only HOT 2
- katago-v1.15.3-opencl-windows-x64 Server returned error 400: This version of KataGo is not enabled for distributed. HOT 2
- trt 15.3 causes system crashes
- Training of human-like models HOT 4
- The Homebrew version is still 1.14.1 HOT 4
- What are the difference between ancient-territory and stone-scoring rules? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from katago.