Weights of leela-zero are txt files, how can I convert it to a model file in ELF? The model in ELF is a pytorch model file. Could anyone give some helps?
Take a look at this script for converting from ELF to LZ: https://github.com/gcp/leela-zero/blob/master/training/elf/elf_convert.py. You just need to do the inverse of it. No need to do the inverse of gamma and beta transformations. Just put bias to bias, set all gammas to 1 and betas to 0. Then permutate input convolution weights to ELF order.
The tricky part is making a valid torch model file that ELF can understand. You can take a look at https://github.com/pytorch/ELF/blob/master/src_py/elfgames/go/df_model3.py on how to make a model. Then you should be able to just replace the weights in it and save it.
Finally you need to modify ELF source code to support value head output from the current player's point of view. Basically inverse of this commit: https://github.com/gcp/leela-zero/commit/f867489a4054418fb10559cb66dc799a33fc8e82. Maybe you can put the inversion in the model file to avoid needing to modify the source coude?
@Ttl I鈥檓 really appreciated for your advice! Since I'm a newbie to those projects, I have trouble reading these source codes. I will follow your steps to start the conversion. Thank you!
If you have V100, could you do a test : )
closing older issues, no discussion for >6 months
Most helpful comment
Take a look at this script for converting from ELF to LZ: https://github.com/gcp/leela-zero/blob/master/training/elf/elf_convert.py. You just need to do the inverse of it. No need to do the inverse of gamma and beta transformations. Just put bias to bias, set all gammas to 1 and betas to 0. Then permutate input convolution weights to ELF order.
The tricky part is making a valid torch model file that ELF can understand. You can take a look at https://github.com/pytorch/ELF/blob/master/src_py/elfgames/go/df_model3.py on how to make a model. Then you should be able to just replace the weights in it and save it.
Finally you need to modify ELF source code to support value head output from the current player's point of view. Basically inverse of this commit: https://github.com/gcp/leela-zero/commit/f867489a4054418fb10559cb66dc799a33fc8e82. Maybe you can put the inversion in the model file to avoid needing to modify the source coude?