Life In 19x19
http://lifein19x19.com/

New android app "BadukAI"
http://lifein19x19.com/viewtopic.php?f=18&t=17784
Page 12 of 27

Author:  And [ Mon Nov 09, 2020 10:11 am ]
Post subject:  Re: New android app "BadukAI"

in Sabaki, KataGo 1.6.1 with g65 network did not work. I tried it this way and that ...

Author:  lightvector [ Mon Nov 09, 2020 10:19 am ]
Post subject:  Re: New android app "BadukAI"

@And, you shouldn't want to use the g65 networks at all, even if you want weaker networks. Even if you get them to work, they won't support the right rulesets and features that the newer neural nets support.

Go here:
https://d3dndmfyhecmj0.cloudfront.net/g ... index.html

And click on the link "selfplayhistory" just below where it says "Full History of Self-Play Nets". You should see the entire history of nets from g170, starting all the way from the very first neural net following purely random play, going all the way to the final nets of the run. If you want weaker nets, try testing out some of the early nets in here.

Author:  And [ Mon Nov 09, 2020 10:25 am ]
Post subject:  Re: New android app "BadukAI"

wow! thanks!!! I thought that there were only two g170 6b!

Author:  And [ Mon Nov 09, 2020 10:32 am ]
Post subject:  Re: New android app "BadukAI"

@lightvector

thanks again! connected 6b to KataGo 1.6.1! now I'll try with CS Zero!

Author:  akigo [ Mon Nov 09, 2020 2:52 pm ]
Post subject:  Re: New android app "BadukAI"

go4thewin wrote:
@akigo
edit: nevermind, guess everything comes from ai.py. it seems to use the policy output though?
Do you have to add or remove any lines to ai.py to get it to work in android, or is self contained? Thanks!


ai.py contains several bot types, I only extracted the parts that are relevant for the kyu-rank bot. It is not self-contained as it uses data like "board state" and "policy values" which come from outside. Therefore I had to make some modifications to adapt this to the environment of BadukAI.

This also means that you can't "run" it stand-alone.

As for android, generally speaking it's no problem to run python code on android. There are python interpreters for android which you can feed the same python sources as on windows or linux (at least if they don't involve too specific OS interaction).

Author:  go4thewin [ Tue Nov 10, 2020 5:48 am ]
Post subject:  Re: New android app "BadukAI"

@akigo
Thanks for the time and clear explanation. Is it easy to get Baduk Ai to read txt.gz nets? I know its a minor inconvenience, but i was playing an older g170 6b net (s114), and the net plays more human like (plays some openings on star points, and other things) than the newest 6b net. The 1 playout policy still is strong (>gtp4zen6 1 dan). Might not be possible, but thought I'd try!

Author:  And [ Tue Nov 10, 2020 7:20 am ]
Post subject:  Re: New android app "BadukAI"

network g170 6 block d7.09M probably plays on 2k.
this network 1p - CS Zero 1k 0:2
this network 1p - CS Zero 2k 2:0
this network 1p - gtp4zen 1k (Zen7 -t4 -s1600 -n1 -o1.6 -p0.3) 1:9

I played a little - this is a completely different game compared to 2k katrain !!!

Author:  And [ Tue Nov 10, 2020 7:43 am ]
Post subject:  Re: New android app "BadukAI"

go4thewin wrote:
Is it easy to get Baduk Ai to read txt.gz nets?

yes it will be very good! playing with katrain kyu-rank is not even interesting :)

Author:  And [ Tue Nov 10, 2020 8:10 am ]
Post subject:  Re: New android app "BadukAI"

@lightvector

maybe there is a script to convert network.txt to .bin?

Author:  go4thewin [ Tue Nov 10, 2020 10:18 am ]
Post subject:  Re: New android app "BadukAI"

I tried converting model.txt to a bin file using binary viewer https://www.proxoft.com/BinaryViewer.aspx and then gzipping the bin file to bin.gz, but didn't work for me in sabaki.

Author:  And [ Tue Nov 10, 2020 10:35 am ]
Post subject:  Re: New android app "BadukAI"

bin file contains data for various purposes, some in decimal form, but how the weights are stacked is a mystery :)

Author:  lightvector [ Tue Nov 10, 2020 12:46 pm ]
Post subject:  Re: New android app "BadukAI"

You could always dig through the KataGo source code and see what the format it's expecting is. It's no mystery, the code is all there. :razz:

There are two ways to get a .bin.gz format. The first way is to export the original tensorflow weights again. Both the .bin.gz and .txt.gz are produced from the tensorflow weights, originally. You can download the tensorflow weights from the exact same site - it's the "saved_model" directory within the same zip file. You'll need to have tensorflow 1.15 installed and run a command like

Code:
python3 export_model.py -saved-model-dir /path/to/saved_model -export-dir /path/to/write/the/result -model-name NAME_OF_MODEL(like "g170-...") -name-scope "swa_model" -filename-prefix model -for-cuda


Where export_model.py is https://github.com/lightvector/KataGo/b ... t_model.py. Replace the arguments to -saved-model-dir and -export-dir and -model-name with the correct things.

The second way is to manually do the conversion yourself. There's no script yet, but the format is straightforward, so you could write won if you wanted. In the .txt format you'll see periodically a huge chunk of floating point values. Followed by a little more metadata, and another huge chunk of floating point values, and so on.

The .bin format is exactly the same except every time there's a huge chunk of floats, instead of writing out the floats in text, it goes "@BIN@" and then followed by all of the bytes of the floats in raw binary (little endian). Un-gzip both files and open them in notepad or notepad++ or something, and you can compare. You can see the code that writes them here: https://github.com/lightvector/KataGo/b ... el.py#L135

So you would have to write a script that every time it encounters a line containing a big block of floats, it parses all of them and outputs raw bytes, and it also writes "@BIN@" at the start of the line. Anything that isn't a big block of floats (like a line containing a string, or a line with a single integer value), it just outputs that line unchanged.

(edit: fixed typo tensorflow 1.5 -> 1.15)

Author:  go4thewin [ Tue Nov 10, 2020 2:16 pm ]
Post subject:  Re: New android app "BadukAI"

@lightvector This is great, thanks so much.
I installed tensorflow 1.5, downloaded export_model.py in the saved_model folde and ran the following command
Code:
python export_model.py -saved-model-dir C:\Users\Go4thewin\Downloads\b6c96-s114663168-d17072879\b6c96-s114663168-d17072879\saved_model -export-dir C:\Users\Go4thewin\Downloads\b6c96-s114663168-d17072879\b6c96-s114663168-d17072879\ -model-name b6c96-s114663168-d17072879 -name-scope "swa_model" -filename-prefix model


then I get the following result in the command line
Code:
   filename_prefix: model
Building model
Traceback (most recent call last):
  File "export_model.py", line 60, in <module>
    with tf.compat.v1.variable_scope(name_scope):
AttributeError: module 'tensorflow.python.util.compat' has no attribute 'v1'


If anyone can help me with what I did wrong, it would be much appreciated. Only if I'm typing something wrong. If it's a technical error, then no problem. Thanks! I think this net is around time parity with gtp4zen 6, except maybe weaker than the very strongest (7d) rank.

Author:  akigo [ Tue Nov 10, 2020 3:15 pm ]
Post subject:  Re: New android app "BadukAI"

go4thewin wrote:
@akigo
Thanks for the time and clear explanation. Is it easy to get Baduk Ai to read txt.gz nets? I know its a minor inconvenience, but i was playing an older g170 6b net (s114), and the net plays more human like (plays some openings on star points, and other things) than the newest 6b net. The 1 playout policy still is strong (>gtp4zen6 1 dan). Might not be possible, but thought I'd try!


I think I can add that in the next version, but I have another feature "in progress", therefore I can't release anything at the moment. So please have some patience.

Author:  lightvector [ Tue Nov 10, 2020 3:44 pm ]
Post subject:  Re: New android app "BadukAI"

go4thewin wrote:
If anyone can help me with what I did wrong, it would be much appreciated. Only if I'm typing something wrong. If it's a technical error, then no problem. Thanks! I think this net is around time parity with gtp4zen 6, except maybe weaker than the very strongest (7d) rank.


I typoed my post - you need tensorflow 1.15, not 1.5. (hence the error you got - about versions and "compat"ibility).

Author:  akigo [ Wed Nov 11, 2020 4:11 pm ]
Post subject:  Re: New android app "BadukAI"

I made a new version (0.17) which also loads .txt.gz KataGo models.

Author:  And [ Thu Nov 12, 2020 5:05 am ]
Post subject:  Re: New android app "BadukAI"

new KaTrain will probably be much better than kyu-rank:

1.5.1 Pre-release: Experimental simple style AIs https://github.com/sanderland/katrain/releases
"Specifically it includes some AI options that are intended to play in a 'simple' way, but still leverage the full power of KataGo, avoiding some of the blind spots that the policy based AIs have."

Author:  go4thewin [ Thu Nov 12, 2020 7:36 am ]
Post subject:  Re: New android app "BadukAI"

akigo wrote:
I made a new version (0.17) which also loads .txt.gz KataGo models.

Really love this app now. from the older s114 6b net kyu rank 7 to 4 threads 100 visits is a huge range of difficulty levels all the way up to mid dan, and makes fast moves even on older phones/tablets. the policy net and above are all very human like, and all the difficulty levels are really fun to play against.
this is an amazon review from a Japanese 4 dan of the zen6 5 dan bot that the katago net can beat

"It is a stringent and dependable master.
Reviewed in Japan on February 19, 2017
Verified Purchase
For amateur four dan me, at first it seemed ruthless, ruthless, killer. (My game in black number 4 stage, Zenith in white five dan)
Over the past month, repeated consecutive defeat, rejections, was held recently in the Go tournament of the same club held, suddenly became the third place, whats the goods.
Members have praised that people have become stronger as they have changed. Now it seems like a reliable master. It is so humanity as well.
The included learning software is also fun.
In the near future, we will defeat the zenith and give back , It is determined. But I'm worried about getting so strong and losing my friends."
I have the same worries as him with Baduk Ai, but oh well lol

Attachments:
File comment: zen6 5 dan was windows zen 6 application, not gtp4zen. 6b was s114 4 threads 100 max visits
6bs114t4visit100VSzen65dan.sgf [1.48 KiB]
Downloaded 298 times

Author:  And [ Wed Nov 18, 2020 9:26 am ]
Post subject:  Re: New android app "BadukAI"

KaTrain simple style(2d) - CS Zero 2d 2:0 (B+R, W+R)
KaTrain simple style(2d) - CS Zero 3d 2:0 (B+R, W+R)
KaTrain simple style(2d) - CS Zero 4d 2:0 (B+R, W+R)

Author:  And [ Thu Nov 19, 2020 6:30 am ]
Post subject:  Re: New android app "BadukAI"

KaTrain simple style(2d) - CS Zero 7d 1:1 (B+, B+)
KaTrain simple style(2d) - CS Zero 8d 1:1 (B+, B+)


Attachments:
katrain - cs zero.sgf [1.58 KiB]
Downloaded 674 times

Page 12 of 27 All times are UTC - 8 hours [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/