New android app "BadukAI"

For discussing go computing, software announcements, etc.
go4thewin
Lives with ko
Posts: 150
Joined: Thu Jan 23, 2020 6:09 am
Rank: 25 kyu
GD Posts: 0
Has thanked: 200 times
Been thanked: 30 times

Re: New android app "BadukAI"

Post by go4thewin »

@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!
And
Gosei
Posts: 1464
Joined: Tue Sep 25, 2018 10:28 am
GD Posts: 0
Has thanked: 212 times
Been thanked: 215 times

Re: New android app "BadukAI"

Post by And »

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 !!!
And
Gosei
Posts: 1464
Joined: Tue Sep 25, 2018 10:28 am
GD Posts: 0
Has thanked: 212 times
Been thanked: 215 times

Re: New android app "BadukAI"

Post by And »

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 :)
And
Gosei
Posts: 1464
Joined: Tue Sep 25, 2018 10:28 am
GD Posts: 0
Has thanked: 212 times
Been thanked: 215 times

Re: New android app "BadukAI"

Post by And »

@lightvector

maybe there is a script to convert network.txt to .bin?
go4thewin
Lives with ko
Posts: 150
Joined: Thu Jan 23, 2020 6:09 am
Rank: 25 kyu
GD Posts: 0
Has thanked: 200 times
Been thanked: 30 times

Re: New android app "BadukAI"

Post by go4thewin »

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.
And
Gosei
Posts: 1464
Joined: Tue Sep 25, 2018 10:28 am
GD Posts: 0
Has thanked: 212 times
Been thanked: 215 times

Re: New android app "BadukAI"

Post by And »

bin file contains data for various purposes, some in decimal form, but how the weights are stacked is a mystery :)
lightvector
Lives in sente
Posts: 759
Joined: Sat Jun 19, 2010 10:11 pm
Rank: maybe 2d
GD Posts: 0
Has thanked: 114 times
Been thanked: 916 times

Re: New android app "BadukAI"

Post by lightvector »

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: Select all

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)
Last edited by lightvector on Tue Nov 10, 2020 3:43 pm, edited 1 time in total.
go4thewin
Lives with ko
Posts: 150
Joined: Thu Jan 23, 2020 6:09 am
Rank: 25 kyu
GD Posts: 0
Has thanked: 200 times
Been thanked: 30 times

Re: New android app "BadukAI"

Post by go4thewin »

@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: Select all

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: Select all

   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.
Last edited by go4thewin on Thu Nov 12, 2020 7:39 am, edited 3 times in total.
akigo
Lives with ko
Posts: 186
Joined: Sun Jun 28, 2020 11:20 am
GD Posts: 0
Has thanked: 13 times
Been thanked: 154 times

Re: New android app "BadukAI"

Post by akigo »

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.
lightvector
Lives in sente
Posts: 759
Joined: Sat Jun 19, 2010 10:11 pm
Rank: maybe 2d
GD Posts: 0
Has thanked: 114 times
Been thanked: 916 times

Re: New android app "BadukAI"

Post by lightvector »

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).
akigo
Lives with ko
Posts: 186
Joined: Sun Jun 28, 2020 11:20 am
GD Posts: 0
Has thanked: 13 times
Been thanked: 154 times

Re: New android app "BadukAI"

Post by akigo »

I made a new version (0.17) which also loads .txt.gz KataGo models.
And
Gosei
Posts: 1464
Joined: Tue Sep 25, 2018 10:28 am
GD Posts: 0
Has thanked: 212 times
Been thanked: 215 times

Re: New android app "BadukAI"

Post by And »

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."
go4thewin
Lives with ko
Posts: 150
Joined: Thu Jan 23, 2020 6:09 am
Rank: 25 kyu
GD Posts: 0
Has thanked: 200 times
Been thanked: 30 times

Re: New android app "BadukAI"

Post by go4thewin »

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
6bs114t4visit100VSzen65dan.sgf
zen6 5 dan was windows zen 6 application, not gtp4zen. 6b was s114 4 threads 100 max visits
(1.48 KiB) Downloaded 632 times
And
Gosei
Posts: 1464
Joined: Tue Sep 25, 2018 10:28 am
GD Posts: 0
Has thanked: 212 times
Been thanked: 215 times

Re: New android app "BadukAI"

Post by And »

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)
And
Gosei
Posts: 1464
Joined: Tue Sep 25, 2018 10:28 am
GD Posts: 0
Has thanked: 212 times
Been thanked: 215 times

Re: New android app "BadukAI"

Post by And »

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 1539 times
Post Reply