yilundu / improved_contrastive_divergence

[ICML'21] Improved Contrastive Divergence Training of Energy Based Models
61 stars 14 forks source link

HeirNet #2

Closed rfelixmg closed 3 years ago

rfelixmg commented 3 years ago

Hi, First, thanks for making the code available. Unfortunately, I've tried to run CelebA training, but I keep bumping into the following error.

Traceback (most recent call last):
  File "train.py", line 1031, in <module>
    main()
  File "train.py", line 651, in main
    heir_model = HeirNet(num_channels=FLAGS.cond_func)
NameError: name 'HeirNet' is not defined

In a attempt to go around this, I've tried to:

        if FLAGS.heir_mask:
            heir_model = HeirNet(num_channels=FLAGS.cond_func)

However, I crossed a different error:

Building graph...
Traceback (most recent call last):
  File "train.py", line 1031, in <module>
    main()
  File "train.py", line 861, in main
    steps, x_mod, attention_mask = tf.while_loop(c_cond, langevin_step, (steps, x_mod, attention_mask))
  File "/opt/anaconda/anaconda3/envs/ebm/lib/python3.6/site-packages/tensorflow/python/ops/control_flow_ops.py", line 3556, in while_loop
    return_same_structure)
  File "/opt/anaconda/anaconda3/envs/ebm/lib/python3.6/site-packages/tensorflow/python/ops/control_flow_ops.py", line 3087, in BuildLoop
    pred, body, original_loop_vars, loop_vars, shape_invariants)
  File "/opt/anaconda/anaconda3/envs/ebm/lib/python3.6/site-packages/tensorflow/python/ops/control_flow_ops.py", line 3022, in _BuildLoop
    body_result = body(*packed_vars_for_body)
  File "train.py", line 810, in langevin_step
    stop_batch=True)
TypeError: forward() got multiple values for argument 'reuse'

My configs: Ubuntu 18.04 tensorflow-gpu==1.13.1 cuda-10.0 cudnn==7.5 nvidia-driver=460**

yilundu commented 3 years ago

Hey!

It might be easier to use the Pytorch code included in this repo to train the CelebA models. You can run

python train.py --dataset=celeba --exp=celeba_model --step_lr=500.0 --num_steps=40 --kl=True --gpus=1 --filter_dim=128 --multiscale --self_attn --reservoir --cond --cond_idx `

to train the individual models and utilize

https://github.com/yilundu/improved_contrastive_divergence/blob/master/celeba_combine.py

to combine the models. I can also take a look in the tensorflow code instead also if you would like to instead run that. The HeirNet model should not be required and can be deleted.

rfelixmg commented 3 years ago

Thank you! I'll give it a try.