Pytorch implement of arXiv paper: Shuo-Hui Li and Lei Wang, Neural Network Renormalization Group arXiv:1802.02840.
NeuralRG is a deep generative model using variational renormalization group approach, it's also a kind of normalizing flow, it is composed by layers of bijectors (In our implementation, we use realNVP). After training, it can generate statistically independent physical configurations with tractable likelihood via directly sampling.
In NeuralRG Network(a), we use realNVP (b) networks as building blocks, realNVP is a kind of bijectors(a normalizing flow), they can transform one distribution into other distribution and revert this process. For multi-in-multi-out blocks, we call they disentanglers(gray blocks in (a)), and for multi-in-single-out blocks, we can they decimators(white blocks in (a)). And stacking multiple layers of these blocks into a hierarchical structure forms NeuralRG network, so NeuralRG is also a bijector. In inference process, each layer tries to "separate" entangled variables into independent variables, and at layers composed of decimators, we only keep one of these independent variables, this is renormalization group.
The structure we used to construct realNVP networks into NeuralRG network is inspired by multi-scale entanglement renormalization ansatz (MERA), as shown in (a). Also, the process of variable going through our network can be viewed as a renormalization process.
The resulted effect of a trained NeuralRG network can be visualized using gradients plot (a) and MI plot of variables of the same layer (b)(c). The latent variables of NeuralRG appears to be a nonlinear and adaptive generalization of wavelet basis.
Use main.py to train model. Options available are:
folderspecifies saving path. At that path aparameters.hdf5will be created to keep training parameters, apicfolder will be created to keep plots, arecordsfolder will be created to keep saved HMC records, and asavingsfolder to save models in.namespecifies model's name. If not specified, a name will be created according to training parameters.epochs,batch,lr,savePeriodare the number of training epochs, batch size, learning rate, the number of epochs before saving.cudaindicates on which GPU card should the model be trained, the default value is -1, which means running on CPU.doubleindicates if use double float.loadindicates if load a pre-trained model. If true, will try to find a pre-trained model at wherefoldersuggests. Note that if true all other parameters will be overwritten with what saved infolder'sparameters.hdf5.nmlp,nhiddenare used to construct MLP networks inside of realNVP networks.nmlpis the number of layers in MLP networks andnhiddenis the number of hidden neurons in each layer.nlayersis used to construct realNVP networks, it suggests how many layers in each realNVP networks.nrepeatis used to construct MERA network, it suggests how many layers of bijectors inside of each layer of MERA network.L,d,Tare used to construct the Ising model to learn,Lis the size of configuration,dis the dimension, andTis the temperature.alpha,symmetryare options about symmetried , symmetrized will be used if use-symmetryoption. If-symmetryoption is not added,-alphacan add a regulation term to loss to try to inflate symmetry.skipHMCis used to skip HMC process during training save memory.
For example, to train the Ising model mentioned in our paper:
python ./main.py -epochs 5000 -folder ./opt/16Ising -batch 512 -nlayers 10 -nmlp 3 -nhidden 10 -L 16 -nrepeat 1 -savePeriod 100 -symmetryUse plot.py to plot the loss curve and HMC results. Options available are:
folderspecifies saving path.plot.pywill use the data saved in that path to plot. And ifsaveis true, the plot will be saved infolder'spicfolder.perspecifies how many seconds between each refresh.show,savespecifies if will show/save the plot.exactspecifies the exact result of HMC.
For example, to plot along with the training process mentioned above:
python ./plot.py -folder ./opt/16Ising -per 30 -exact 0.544445Change settings in settings.py to train diffierent models in different temperatures and different depths. Then python core.py will read these settings and train these models. Figure of relative loss of different temperatures and depths can be plotted using paperplot/plotCore.py.
If you use this code for your research, please cite our paper:
@article{neuralRG,
Author = {Shuo-Hui Li and Lei Wang},
Title = {Neural Network Renormalization Group},
Year = {2018},
Eprint = {arXiv:1802.02840},
}
For questions and suggestions, contact Shuo-Hui Li at contact_lish@iphy.ac.cn.

